From: Christoph Egger Date: Tue, 27 May 2014 12:35:18 +0000 (+0200) Subject: Avoid memory leak X-Git-Tag: v0.1~199 X-Git-Url: https://git.siccegge.de//index.cgi?a=commitdiff_plain;h=f5b948bf38d8757f4e9a0d7af4edaa4a6fffec27;p=frida%2Ffrida.git Avoid memory leak --- diff --git a/src/disassembler/llvm/LLVMDisassembler.cxx b/src/disassembler/llvm/LLVMDisassembler.cxx index 3494b79..7bce1cf 100644 --- a/src/disassembler/llvm/LLVMDisassembler.cxx +++ b/src/disassembler/llvm/LLVMDisassembler.cxx @@ -110,6 +110,16 @@ LLVMDisassembler::LLVMDisassembler(const std::string& filename) disassemble(); } +LLVMDisassembler::~LLVMDisassembler() { + std::for_each(functions.begin(), functions.end(), + [](std::pair it) { + delete it.second; + }); + std::for_each(blocks.begin(), blocks.end(), + [](std::pair it) { + delete it.second; + }); +} void LLVMDisassembler::disassemble() { std::stack remaining_functions; diff --git a/src/disassembler/llvm/LLVMDisassembler.hxx b/src/disassembler/llvm/LLVMDisassembler.hxx index 87dbefa..42024ee 100644 --- a/src/disassembler/llvm/LLVMDisassembler.hxx +++ b/src/disassembler/llvm/LLVMDisassembler.hxx @@ -11,13 +11,14 @@ #include "disassembler/BasicBlock.hxx" #include "disassembler/Function.hxx" #include "disassembler/llvm/LLVMBasicBlock.hxx" +#include "disassembler/llvm/LLVMFunction.hxx" class LLVMDisassembler : public Disassembler { public: LLVMDisassembler(const std::string& filename); - virtual ~LLVMDisassembler() {}; + virtual ~LLVMDisassembler(); void getSymbols(); uint64_t entryAddress();