diff options
author | Mircea Trofin <mtrofin@google.com> | 2024-06-03 12:46:08 -0700 |
---|---|---|
committer | Mircea Trofin <mtrofin@google.com> | 2024-06-03 12:48:23 -0700 |
commit | c49bc1a3b782e38e4ffb5b274f1e7775af6c2315 (patch) | |
tree | 7002cd6e34a7c87fb2c872d3edecce2deb2af84b /llvm/lib/Bitcode | |
parent | cf3b37c92ffad21086a0741ac682c87abea9a5d6 (diff) | |
download | llvm-c49bc1a3b782e38e4ffb5b274f1e7775af6c2315.zip llvm-c49bc1a3b782e38e4ffb5b274f1e7775af6c2315.tar.gz llvm-c49bc1a3b782e38e4ffb5b274f1e7775af6c2315.tar.bz2 |
BitcodeWriter: ensure `Buffer` is heap allocated
PR #92983 accidentally changed the buffer allocation in
`llvm::WriteBitcodeToFile` to be allocated on the stack, which is
problematic given it's a large-ish buffer (256K)
Diffstat (limited to 'llvm/lib/Bitcode')
-rw-r--r-- | llvm/lib/Bitcode/Writer/BitcodeWriter.cpp | 3 |
1 files changed, 2 insertions, 1 deletions
diff --git a/llvm/lib/Bitcode/Writer/BitcodeWriter.cpp b/llvm/lib/Bitcode/Writer/BitcodeWriter.cpp index 7d39c0d..9016af7 100644 --- a/llvm/lib/Bitcode/Writer/BitcodeWriter.cpp +++ b/llvm/lib/Bitcode/Writer/BitcodeWriter.cpp @@ -5095,7 +5095,8 @@ void llvm::WriteBitcodeToFile(const Module &M, raw_ostream &Out, // header. Note that the header is computed *after* the output is known, so // we currently explicitly use a buffer, write to it, and then subsequently // flush to Out. - SmallVector<char, 256 * 1024> Buffer; + SmallVector<char, 0> Buffer; + Buffer.reserve(256 * 1024); Buffer.insert(Buffer.begin(), BWH_HeaderSize, 0); BitcodeWriter Writer(Buffer); Write(Writer); |