aboutsummaryrefslogtreecommitdiff
path: root/backends/plugins
diff options
context:
space:
mode:
authorYotam Barnoy2010-12-26 20:44:19 +0000
committerYotam Barnoy2010-12-26 20:44:19 +0000
commit4f3623964465a6d42d99b0fa37ba9073e948c79f (patch)
treea492d4f2925376d77252e6e098c993613d2e311a /backends/plugins
parentf9409fc7d50de09186ba30b28fe9ae1ad58067ca (diff)
downloadscummvm-rg350-4f3623964465a6d42d99b0fa37ba9073e948c79f.tar.gz
scummvm-rg350-4f3623964465a6d42d99b0fa37ba9073e948c79f.tar.bz2
scummvm-rg350-4f3623964465a6d42d99b0fa37ba9073e948c79f.zip
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
Diffstat (limited to 'backends/plugins')
-rw-r--r--backends/plugins/elf/elf-loader.cpp12
1 files changed, 10 insertions, 2 deletions
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
}