From 2319c0e2157137d73f6fe67aaa32d21057b927ff Mon Sep 17 00:00:00 2001 From: Pranav Kant Date: Fri, 22 Nov 2024 18:59:43 +0000 Subject: [PATCH] [BitstreamReader] Fix 32-bit overflow when processing large LTO-generated files --- llvm/lib/Bitstream/Reader/BitstreamReader.cpp | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/llvm/lib/Bitstream/Reader/BitstreamReader.cpp b/llvm/lib/Bitstream/Reader/BitstreamReader.cpp index 5b2c76350029b..fed9994db2ae8 100644 --- a/llvm/lib/Bitstream/Reader/BitstreamReader.cpp +++ b/llvm/lib/Bitstream/Reader/BitstreamReader.cpp @@ -334,7 +334,8 @@ Expected BitstreamCursor::readRecord(unsigned AbbrevID, // Figure out where the end of this blob will be including tail padding. size_t CurBitPos = GetCurrentBitNo(); - const size_t NewEnd = CurBitPos + alignTo(NumElts, 4) * 8; + const size_t NewEnd = + CurBitPos + static_cast(alignTo(NumElts, 4)) * 8; // Make sure the bitstream is large enough to contain the blob. if (!canSkipToPos(NewEnd/8))