diff options
author | Andre Heider | 2010-09-05 21:59:50 +0000 |
---|---|---|
committer | Andre Heider | 2010-09-05 21:59:50 +0000 |
commit | 4c7f5084c2e5e10942d2f5d8dfffb4a7f3258ad5 (patch) | |
tree | ff6eb5dc6e709b06f2492c75ff95dbb80203dbd2 | |
parent | a4c9de25e62c02c0f3920c4bc568f69a01b2deaa (diff) | |
download | scummvm-rg350-4c7f5084c2e5e10942d2f5d8dfffb4a7f3258ad5.tar.gz scummvm-rg350-4c7f5084c2e5e10942d2f5d8dfffb4a7f3258ad5.tar.bz2 scummvm-rg350-4c7f5084c2e5e10942d2f5d8dfffb4a7f3258ad5.zip |
PLUGINS: Plug some memleaks.
svn-id: r52575
-rw-r--r-- | backends/plugins/elf/elf-loader.cpp | 16 | ||||
-rw-r--r-- | backends/plugins/elf/elf-provider.cpp | 3 |
2 files changed, 14 insertions, 5 deletions
diff --git a/backends/plugins/elf/elf-loader.cpp b/backends/plugins/elf/elf-loader.cpp index 202444ed4b..7bdec22508 100644 --- a/backends/plugins/elf/elf-loader.cpp +++ b/backends/plugins/elf/elf-loader.cpp @@ -51,16 +51,20 @@ DLObject::~DLObject() { // Expel the symbol table from memory void DLObject::discard_symtab() { free(_symtab); - free(_strtab); _symtab = 0; + + free(_strtab); _strtab = 0; + _symbol_cnt = 0; } // Unload all objects from memory void DLObject::unload() { discard_symtab(); + freeSegment(_segment); + _segment = 0; _segmentSize = 0; _segmentOffset = 0; @@ -207,6 +211,7 @@ Elf32_Shdr * DLObject::loadSectionHeaders(Elf32_Ehdr *ehdr) { _file->read(shdr, ehdr->e_shnum * sizeof(*shdr)) != ehdr->e_shnum * sizeof(*shdr)) { warning("elfloader: Section headers load failed."); + free(shdr); return 0; } @@ -247,6 +252,8 @@ int DLObject::loadSymbolTable(Elf32_Ehdr *ehdr, Elf32_Shdr *shdr) { _file->read(_symtab, shdr[_symtab_sect].sh_size) != shdr[_symtab_sect].sh_size) { warning("elfloader: Symbol table load failed."); + free(_symtab); + _symtab = 0; return -1; } @@ -273,6 +280,8 @@ bool DLObject::loadStringTable(Elf32_Shdr *shdr) { _file->read(_strtab, shdr[string_sect].sh_size) != shdr[string_sect].sh_size) { warning("elfloader: Symbol table strings load failed."); + free(_strtab); + _strtab = 0; return false; } @@ -314,8 +323,9 @@ bool DLObject::load() { return false; } - if (!(shdr = loadSectionHeaders(&ehdr))) - ret = false; + shdr = loadSectionHeaders(&ehdr); + if (!shdr) + return false; if (ret && ((_symtab_sect = loadSymbolTable(&ehdr, shdr)) < 0)) ret = false; diff --git a/backends/plugins/elf/elf-provider.cpp b/backends/plugins/elf/elf-provider.cpp index a7d2d779d8..7bb39d4347 100644 --- a/backends/plugins/elf/elf-provider.cpp +++ b/backends/plugins/elf/elf-provider.cpp @@ -71,8 +71,7 @@ bool ELFPlugin::loadPlugin() { bool ret = DynamicPlugin::loadPlugin(); - if (ret && _dlHandle) - _dlHandle->discard_symtab(); + _dlHandle->discard_symtab(); return ret; } |