]> git.siccegge.de Git - frida/frida.git/commitdiff
Avoid memory leak
authorChristoph Egger <siccegge@cs.fau.de>
Tue, 27 May 2014 12:35:18 +0000 (14:35 +0200)
committerChristoph Egger <siccegge@cs.fau.de>
Tue, 27 May 2014 12:35:18 +0000 (14:35 +0200)
src/disassembler/llvm/LLVMDisassembler.cxx
src/disassembler/llvm/LLVMDisassembler.hxx

index 3494b79bd8a370814d35eba28fec53db0e1543d6..7bce1cf6ab2107d4ff9d237149919769b8431a0f 100644 (file)
@@ -110,6 +110,16 @@ LLVMDisassembler::LLVMDisassembler(const std::string& filename)
     disassemble();
 }
 
+LLVMDisassembler::~LLVMDisassembler() {
+       std::for_each(functions.begin(), functions.end(),
+                                 [](std::pair<uint64_t,LLVMFunction*> it) {
+                                         delete it.second;
+                                 });
+       std::for_each(blocks.begin(), blocks.end(),
+                                 [](std::pair<uint64_t, LLVMBasicBlock*> it) {
+                                         delete it.second;
+                                 });
+}
 
 void LLVMDisassembler::disassemble() {
     std::stack<LLVMFunction*> remaining_functions;
index 87dbefa2c9ed355349dcf892aac5a3a936614dae..42024ee7c4998839f796c7d55ea43ea45ccd8a2b 100644 (file)
 #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();