From 6aeb31b5f0cb1063b74b062bf453b111477ff808 Mon Sep 17 00:00:00 2001 From: Peter Collingbourne Date: Mon, 26 Oct 2015 18:23:21 +0000 Subject: [PATCH] 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. git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@251323 91177308-0d34-0410-b5e6-96231b3b80d8 --- include/llvm/Bitcode/BitstreamWriter.h | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/include/llvm/Bitcode/BitstreamWriter.h b/include/llvm/Bitcode/BitstreamWriter.h index bac6c574708..b13b6045987 100644 --- a/include/llvm/Bitcode/BitstreamWriter.h +++ b/include/llvm/Bitcode/BitstreamWriter.h @@ -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); -- 2.34.1