diff options
author | Reid Spencer <rspencer@reidspencer.com> | 2007-03-03 08:36:29 +0000 |
---|---|---|
committer | Reid Spencer <rspencer@reidspencer.com> | 2007-03-03 08:36:29 +0000 |
commit | f0f09a96f3610f716f8b9da78ec1b30a4c2a75ec (patch) | |
tree | 1519d5614a2dfbd1134d3f98c3e48e46fb53e3bb | |
parent | 47567bdcb5ba3886eaf3fa5f0e0b912a24c12347 (diff) |
Avoid memory leakage by having caller construct the APInt for the
destination value of LoadValueFromMemory.
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@34883 91177308-0d34-0410-b5e6-96231b3b80d8
-rw-r--r-- | lib/ExecutionEngine/ExecutionEngine.cpp | 9 |
1 files changed, 4 insertions, 5 deletions
diff --git a/lib/ExecutionEngine/ExecutionEngine.cpp b/lib/ExecutionEngine/ExecutionEngine.cpp index 55793219bc..ca077fcef0 100644 --- a/lib/ExecutionEngine/ExecutionEngine.cpp +++ b/lib/ExecutionEngine/ExecutionEngine.cpp @@ -578,9 +578,9 @@ Store4BytesLittleEndian: /// FIXME: document /// -GenericValue ExecutionEngine::LoadValueFromMemory(GenericValue *Ptr, +void ExecutionEngine::LoadValueFromMemory(GenericValue &Result, + GenericValue *Ptr, const Type *Ty) { - GenericValue Result; if (getTargetData()->isLittleEndian()) { switch (Ty->getTypeID()) { case Type::IntegerTyID: { @@ -605,7 +605,7 @@ GenericValue ExecutionEngine::LoadValueFromMemory(GenericValue *Ptr, ((uint64_t)Ptr->Untyped[6] << 48) | ((uint64_t)Ptr->Untyped[7] << 56); } else - Result.APIntVal = new APInt(BitWidth, BitWidth/64, (uint64_t*)Ptr); + *(Result.APIntVal) = APInt(BitWidth, BitWidth/64, (uint64_t*)Ptr); break; } Load4BytesLittleEndian: @@ -657,7 +657,7 @@ GenericValue ExecutionEngine::LoadValueFromMemory(GenericValue *Ptr, ((uint64_t)Ptr->Untyped[1] << 48) | ((uint64_t)Ptr->Untyped[0] << 56); } else - Result.APIntVal = new APInt(BitWidth, BitWidth/64, (uint64_t*)Ptr); + *(Result.APIntVal) = APInt(BitWidth, BitWidth/64, (uint64_t*)Ptr); break; } Load4BytesBigEndian: @@ -686,7 +686,6 @@ GenericValue ExecutionEngine::LoadValueFromMemory(GenericValue *Ptr, abort(); } } - return Result; } // InitializeMemory - Recursive function to apply a Constant value into the |