[llvm] 146f486 - [ObjCopy] Fix type mismatch in writeCodeSignatureData()
Daniel RodrÃguez Troitiño via llvm-commits
llvm-commits at lists.llvm.org
Fri Jun 24 09:26:13 PDT 2022
Author: Joshua Root
Date: 2022-06-24T09:14:47-07:00
New Revision: 146f486ba337299b88df303a6f1cf99f60df03cc
URL: https://github.com/llvm/llvm-project/commit/146f486ba337299b88df303a6f1cf99f60df03cc
DIFF: https://github.com/llvm/llvm-project/commit/146f486ba337299b88df303a6f1cf99f60df03cc.diff
LOG: [ObjCopy] Fix type mismatch in writeCodeSignatureData()
The result of pointer subtraction is of type ptrdiff_t, which is not necessarily the same underlying type as ssize_t. This can lead to a compilation error since std::min requires both parameters to be the same type.
Fixes: https://github.com/llvm/llvm-project/issues/54846
Reviewed By: alexander-shaposhnikov, drodriguez, jhenderson
Differential Revision: https://reviews.llvm.org/D128117
Added:
Modified:
llvm/lib/ObjCopy/MachO/MachOWriter.cpp
Removed:
################################################################################
diff --git a/llvm/lib/ObjCopy/MachO/MachOWriter.cpp b/llvm/lib/ObjCopy/MachO/MachOWriter.cpp
index 9b1fd58cc482a..bc633285e03c6 100644
--- a/llvm/lib/ObjCopy/MachO/MachOWriter.cpp
+++ b/llvm/lib/ObjCopy/MachO/MachOWriter.cpp
@@ -520,8 +520,9 @@ void MachOWriter::writeCodeSignatureData() {
uint8_t *CurrHashWritePosition = HashWriteStart;
while (CurrHashReadPosition < HashReadEnd) {
StringRef Block(reinterpret_cast<char *>(CurrHashReadPosition),
- std::min(HashReadEnd - CurrHashReadPosition,
- static_cast<ssize_t>(CodeSignature.BlockSize)));
+ std::min(static_cast<size_t>(HashReadEnd
+ - CurrHashReadPosition),
+ static_cast<size_t>(CodeSignature.BlockSize)));
SHA256 Hasher;
Hasher.update(Block);
std::array<uint8_t, 32> Hash = Hasher.final();
More information about the llvm-commits
mailing list