Skip to content

Commit 5a4541d

Browse files
mtrofinronlieb
authored andcommitted
BitcodeWriter: ensure Buffer is heap allocated
PR llvm#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) Change-Id: I0f30bfb030e160c9b158fa5a5d3451fb1a20c8a9
1 parent 72b990d commit 5a4541d

File tree

1 file changed

+2
-1
lines changed

1 file changed

+2
-1
lines changed

llvm/lib/Bitcode/Writer/BitcodeWriter.cpp

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5275,7 +5275,8 @@ void llvm::WriteBitcodeToFile(const Module &M, raw_ostream &Out,
52755275
// header. Note that the header is computed *after* the output is known, so
52765276
// we currently explicitly use a buffer, write to it, and then subsequently
52775277
// flush to Out.
5278-
SmallVector<char, 256 * 1024> Buffer;
5278+
SmallVector<char, 0> Buffer;
5279+
Buffer.reserve(256 * 1024);
52795280
Buffer.insert(Buffer.begin(), BWH_HeaderSize, 0);
52805281
BitcodeWriter Writer(Buffer);
52815282
Write(Writer);

0 commit comments

Comments
 (0)