summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorPeter Collingbourne <peter@pcc.me.uk>2015-10-26 18:23:21 +0000
committerPeter Collingbourne <peter@pcc.me.uk>2015-10-26 18:23:21 +0000
commit693499cefc75f095a6afae64fcf25137fb309f91 (patch)
treef116def06d830aeb6eb2b3d691d2235106ff0a14
parent97aae40880d76765e9fe2c14ccc8734c1f207414 (diff)
downloadbcm5719-llvm-693499cefc75f095a6afae64fcf25137fb309f91.tar.gz
bcm5719-llvm-693499cefc75f095a6afae64fcf25137fb309f91.zip
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. llvm-svn: 251323
-rw-r--r--llvm/include/llvm/Bitcode/BitstreamWriter.h2
1 files changed, 1 insertions, 1 deletions
diff --git a/llvm/include/llvm/Bitcode/BitstreamWriter.h b/llvm/include/llvm/Bitcode/BitstreamWriter.h
index bac6c574708..b13b6045987 100644
--- a/llvm/include/llvm/Bitcode/BitstreamWriter.h
+++ b/llvm/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);
OpenPOWER on IntegriCloud