From 4ab2d2009e4a16d1a5104047e1e2cdbbf2cb9b1a Mon Sep 17 00:00:00 2001 From: Chris Lattner Date: Tue, 24 Apr 2007 17:20:52 +0000 Subject: fix a memory leak git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@36396 91177308-0d34-0410-b5e6-96231b3b80d8 --- lib/Bytecode/Reader/Reader.cpp | 11 ++++++----- 1 file changed, 6 insertions(+), 5 deletions(-) (limited to 'lib/Bytecode/Reader/Reader.cpp') diff --git a/lib/Bytecode/Reader/Reader.cpp b/lib/Bytecode/Reader/Reader.cpp index 98ed57ea6f..ee6d9e6208 100644 --- a/lib/Bytecode/Reader/Reader.cpp +++ b/lib/Bytecode/Reader/Reader.cpp @@ -1299,11 +1299,12 @@ Value *BytecodeReader::ParseConstantPoolValue(unsigned TypeID) { Result = ConstantInt::get(IT, Val); if (Handler) Handler->handleConstantValue(Result); } else { - uint32_t numWords = read_vbr_uint(); - uint64_t *data = new uint64_t[numWords]; - for (uint32_t i = 0; i < numWords; ++i) - data[i] = read_vbr_uint64(); - Result = ConstantInt::get(APInt(IT->getBitWidth(), numWords, data)); + uint32_t NumWords = read_vbr_uint(); + SmallVector Words; + Words.resize(NumWords); + for (uint32_t i = 0; i < NumWords; ++i) + Words[i] = read_vbr_uint64(); + Result = ConstantInt::get(APInt(IT->getBitWidth(), NumWords, &Words[0])); if (Handler) Handler->handleConstantValue(Result); } break; -- cgit v1.2.3