diff --git a/backends/plugins/elf/elf-loader.cpp b/backends/plugins/elf/elf-loader.cpp index 17a67f4d02e..24a4fda703d 100644 --- a/backends/plugins/elf/elf-loader.cpp +++ b/backends/plugins/elf/elf-loader.cpp @@ -320,24 +320,30 @@ bool DLObject::load() { return false; } - Common::ScopedPtrC shdr(loadSectionHeaders(&ehdr)); + Elf32_Shdr *shdr = loadSectionHeaders(&ehdr); if (!shdr) return false; _symtab_sect = loadSymbolTable(&ehdr, shdr); - if (_symtab_sect < 0) + if (_symtab_sect < 0) { + free(shdr); return false; + } - if (!loadStringTable(shdr)) + if (!loadStringTable(shdr)) { + free(shdr); return false; + } // Offset by our segment allocated address // must use _segmentVMA here for multiple segments (MIPS) _segmentOffset = ptrdiff_t(_segment) - _segmentVMA; relocateSymbols(_segmentOffset); - if (!relocateRels(&ehdr, shdr)) + if (!relocateRels(&ehdr, shdr)) { + free(shdr); return false; + } return true; } diff --git a/common/ptr.h b/common/ptr.h index 383b3ee15d6..4d7fff1fc20 100644 --- a/common/ptr.h +++ b/common/ptr.h @@ -242,17 +242,15 @@ public: */ operator bool() const { return _pointer != 0; } - void deletePointer() { delete _pointer; } - ~ScopedPtr() { - deletePointer(); + delete _pointer; } /** * Resets the pointer with the new value. Old object will be destroyed */ void reset(PointerType o = 0) { - deletePointer(); + delete _pointer; _pointer = o; } @@ -275,20 +273,10 @@ public: return r; } -protected: +private: PointerType _pointer; }; -template -class ScopedPtrC : public ScopedPtr { -public: - typedef T *PointerType; - - explicit ScopedPtrC(PointerType o = 0) : ScopedPtr(o) {} - - void deletePointer() { free(ScopedPtr::_pointer); } -}; - } // End of namespace Common #endif