From 4f3623964465a6d42d99b0fa37ba9073e948c79f Mon Sep 17 00:00:00 2001 From: Yotam Barnoy Date: Sun, 26 Dec 2010 20:44:19 +0000 Subject: PLUGINS: fixed resource leak that caused PSP to crash The leaky file handles didn't show up when debugging using the shell since that uses the Windows file handles, of which there are many more. svn-id: r55048 --- backends/plugins/elf/elf-loader.cpp | 12 ++++++++++-- 1 file changed, 10 insertions(+), 2 deletions(-) (limited to 'backends/plugins/elf') diff --git a/backends/plugins/elf/elf-loader.cpp b/backends/plugins/elf/elf-loader.cpp index 43477e06e2..f502fa2776 100644 --- a/backends/plugins/elf/elf-loader.cpp +++ b/backends/plugins/elf/elf-loader.cpp @@ -332,8 +332,11 @@ void DLObject::trackSize(const char *path) { Elf32_Ehdr ehdr; Elf32_Phdr phdr; - if (!readElfHeader(&ehdr)) + if (!readElfHeader(&ehdr)) { + delete _file; + _file = 0; return; + } ELFMemMan.trackPlugin(true); // begin tracking the plugin size @@ -341,8 +344,11 @@ void DLObject::trackSize(const char *path) { for (uint32 i = 0; i < ehdr.e_phnum; i++) { debug(2, "elfloader: Loading segment %d", i); - if (!readProgramHeaders(&ehdr, &phdr, i)) + if (!readProgramHeaders(&ehdr, &phdr, i)) { + delete _file; + _file = 0; return; + } if (phdr.p_flags & PF_X) { // check for executable, allocated segment ELFMemMan.trackAlloc(phdr.p_align, phdr.p_memsz); @@ -351,6 +357,8 @@ void DLObject::trackSize(const char *path) { ELFMemMan.trackPlugin(false); // we're done tracking the plugin size + delete _file; + _file = 0; // No need to track the symbol table sizes -- they get discarded } -- cgit v1.2.3