Skip to content

Commit 8df6321

Browse files
authored
[BitstreamReader] Fix 32-bit overflow (#117363)
This got exposed when processing large LTO-generated files leading to crashes.
1 parent 80afdbe commit 8df6321

File tree

1 file changed

+2
-1
lines changed

1 file changed

+2
-1
lines changed

llvm/lib/Bitstream/Reader/BitstreamReader.cpp

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -334,7 +334,8 @@ Expected<unsigned> BitstreamCursor::readRecord(unsigned AbbrevID,
334334

335335
// Figure out where the end of this blob will be including tail padding.
336336
size_t CurBitPos = GetCurrentBitNo();
337-
const size_t NewEnd = CurBitPos + alignTo(NumElts, 4) * 8;
337+
const size_t NewEnd =
338+
CurBitPos + static_cast<uint64_t>(alignTo(NumElts, 4)) * 8;
338339

339340
// Make sure the bitstream is large enough to contain the blob.
340341
if (!canSkipToPos(NewEnd/8))

0 commit comments

Comments
 (0)