diff --git a/llvm/lib/ExecutionEngine/JIT/JITDebugRegisterer.cpp b/llvm/lib/ExecutionEngine/JIT/JITDebugRegisterer.cpp index 565509cd1f36..68471bd4d5f4 100644 --- a/llvm/lib/ExecutionEngine/JIT/JITDebugRegisterer.cpp +++ b/llvm/lib/ExecutionEngine/JIT/JITDebugRegisterer.cpp @@ -165,7 +165,7 @@ void JITDebugRegisterer::RegisterFunction(const Function *F, DebugInfo &I) { void JITDebugRegisterer::UnregisterFunctionInternal( RegisteredFunctionsMap::iterator I) { - jit_code_entry *JITCodeEntry = I->second.second; + jit_code_entry *&JITCodeEntry = I->second.second; // Acquire the lock and do the unregistration. { @@ -190,6 +190,9 @@ void JITDebugRegisterer::UnregisterFunctionInternal( __jit_debug_register_code(); } + delete JITCodeEntry; + JITCodeEntry = NULL; + // Free the ELF file in memory. std::string &Buffer = I->second.first; Buffer.clear();