[llvm] r251323 - BitstreamWriter: Fix integer overflow.
Peter Collingbourne via llvm-commits
llvm-commits at lists.llvm.org
Mon Oct 26 11:23:21 PDT 2015
Author: pcc
Date: Mon Oct 26 13:23:21 2015
New Revision: 251323
URL: http://llvm.org/viewvc/llvm-project?rev=251323&view=rev
Log:
BitstreamWriter: Fix integer overflow.
We were previously overflowing a 32-bit multiply operation when emitting large
(>512MB) bitcode files, resulting in corrupted bitcode. Fix by extending
one of the operands to 64 bits.
There are a few other 32-bit integer types in this code that seem like they
also ought to be extended to 64 bits; this will be done separately.
Modified:
llvm/trunk/include/llvm/Bitcode/BitstreamWriter.h
Modified: llvm/trunk/include/llvm/Bitcode/BitstreamWriter.h
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/include/llvm/Bitcode/BitstreamWriter.h?rev=251323&r1=251322&r2=251323&view=diff
==============================================================================
--- llvm/trunk/include/llvm/Bitcode/BitstreamWriter.h (original)
+++ llvm/trunk/include/llvm/Bitcode/BitstreamWriter.h Mon Oct 26 13:23:21 2015
@@ -243,7 +243,7 @@ public:
// Compute the size of the block, in words, not counting the size field.
unsigned SizeInWords = GetWordIndex() - B.StartSizeWord - 1;
- uint64_t BitNo = B.StartSizeWord * 32;
+ uint64_t BitNo = uint64_t(B.StartSizeWord) * 32;
// Update the block size field in the header of this sub-block.
BackpatchWord(BitNo, SizeInWords);
More information about the llvm-commits
mailing list