Skip to content

Commit c49bc1a

Browse files
committed
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)
1 parent cf3b37c commit c49bc1a

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
@@ -5095,7 +5095,8 @@ void llvm::WriteBitcodeToFile(const Module &M, raw_ostream &Out,
50955095
// header. Note that the header is computed *after* the output is known, so
50965096
// we currently explicitly use a buffer, write to it, and then subsequently
50975097
// flush to Out.
5098-
SmallVector<char, 256 * 1024> Buffer;
5098+
SmallVector<char, 0> Buffer;
5099+
Buffer.reserve(256 * 1024);
50995100
Buffer.insert(Buffer.begin(), BWH_HeaderSize, 0);
51005101
BitcodeWriter Writer(Buffer);
51015102
Write(Writer);

0 commit comments

Comments
 (0)