Skip to content

Commit 2319c0e

Browse files
committed
[BitstreamReader] Fix 32-bit overflow when processing large LTO-generated files
1 parent 0e3c791 commit 2319c0e

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)