Skip to content

Commit 146f486

Browse files
jmrootdrodriguez
authored andcommitted
[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: llvm#54846 Reviewed By: alexander-shaposhnikov, drodriguez, jhenderson Differential Revision: https://reviews.llvm.org/D128117
1 parent e422c0d commit 146f486

File tree

1 file changed

+3
-2
lines changed

1 file changed

+3
-2
lines changed

llvm/lib/ObjCopy/MachO/MachOWriter.cpp

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -520,8 +520,9 @@ void MachOWriter::writeCodeSignatureData() {
520520
uint8_t *CurrHashWritePosition = HashWriteStart;
521521
while (CurrHashReadPosition < HashReadEnd) {
522522
StringRef Block(reinterpret_cast<char *>(CurrHashReadPosition),
523-
std::min(HashReadEnd - CurrHashReadPosition,
524-
static_cast<ssize_t>(CodeSignature.BlockSize)));
523+
std::min(static_cast<size_t>(HashReadEnd
524+
- CurrHashReadPosition),
525+
static_cast<size_t>(CodeSignature.BlockSize)));
525526
SHA256 Hasher;
526527
Hasher.update(Block);
527528
std::array<uint8_t, 32> Hash = Hasher.final();

0 commit comments

Comments
 (0)