aboutsummaryrefslogtreecommitdiff
path: root/engines
diff options
context:
space:
mode:
authorMax Horn2008-09-29 11:02:11 +0000
committerMax Horn2008-09-29 11:02:11 +0000
commit392f9ee7fa1e86cce0c9a08e1efc3f79fb2ec290 (patch)
tree79fc385fb104d1d64c7e37c08fc6112bfc2f1be2 /engines
parent18536552e0c13418036f0169cf150cb56f91b80e (diff)
downloadscummvm-rg350-392f9ee7fa1e86cce0c9a08e1efc3f79fb2ec290.tar.gz
scummvm-rg350-392f9ee7fa1e86cce0c9a08e1efc3f79fb2ec290.tar.bz2
scummvm-rg350-392f9ee7fa1e86cce0c9a08e1efc3f79fb2ec290.zip
SCUMM HE: Fixed leak in Win32ResExtractor::extractResource_, use _filename instead of File::name
svn-id: r34683
Diffstat (limited to 'engines')
-rw-r--r--engines/scumm/he/resource_he.cpp25
-rw-r--r--engines/scumm/he/resource_he.h4
2 files changed, 15 insertions, 14 deletions
diff --git a/engines/scumm/he/resource_he.cpp b/engines/scumm/he/resource_he.cpp
index f8fb1efca2..4f74a74b89 100644
--- a/engines/scumm/he/resource_he.cpp
+++ b/engines/scumm/he/resource_he.cpp
@@ -165,7 +165,6 @@ int Win32ResExtractor::extractResource_(const char *resType, char *resName, byte
_fileName = _vm->generateFilename(-3);
}
-
/* get file size */
fi.file->open(_fileName);
if (!fi.file->isOpen()) {
@@ -174,18 +173,18 @@ int Win32ResExtractor::extractResource_(const char *resType, char *resName, byte
fi.total_size = fi.file->size();
if (fi.total_size == -1) {
- error("Cannot get size of file %s", fi.file->name());
+ error("Cannot get size of file %s", _fileName.c_str());
goto cleanup;
}
if (fi.total_size == 0) {
- error("%s: file has a size of 0", fi.file->name());
+ error("%s: file has a size of 0", _fileName.c_str());
goto cleanup;
}
/* read all of file */
fi.memory = (byte *)malloc(fi.total_size);
if (fi.file->read(fi.memory, fi.total_size) == 0) {
- error("Cannot read from file %s", fi.file->name());
+ error("Cannot read from file %s", _fileName.c_str());
goto cleanup;
}
@@ -200,8 +199,10 @@ int Win32ResExtractor::extractResource_(const char *resType, char *resName, byte
/* free stuff and close file */
cleanup:
- if (fi.file != NULL)
+ if (fi.file != NULL) {
fi.file->close();
+ delete fi.file;
+ }
if (fi.memory != NULL)
free(fi.memory);
@@ -371,19 +372,19 @@ byte *Win32ResExtractor::extract_group_icon_cursor_resource(WinLibrary *fi, WinR
fwr = find_resource(fi, (is_icon ? "-3" : "-1"), name, lang, &level);
if (fwr == NULL) {
error("%s: could not find `%s' in `%s' resource.",
- fi->file->name(), &name[1], (is_icon ? "group_icon" : "group_cursor"));
+ _fileName.c_str(), &name[1], (is_icon ? "group_icon" : "group_cursor"));
return NULL;
}
if (get_resource_entry(fi, fwr, &iconsize) != NULL) {
if (iconsize == 0) {
- debugC(DEBUG_RESOURCE, "%s: icon resource `%s' is empty, skipping", fi->file->name(), name);
+ debugC(DEBUG_RESOURCE, "%s: icon resource `%s' is empty, skipping", _fileName.c_str(), name);
skipped++;
continue;
}
if ((uint32)iconsize != FROM_LE_32(icondir->entries[c].bytes_in_res)) {
debugC(DEBUG_RESOURCE, "%s: mismatch of size in icon resource `%s' and group (%d != %d)",
- fi->file->name(), name, iconsize, FROM_LE_32(icondir->entries[c].bytes_in_res));
+ _fileName.c_str(), name, iconsize, FROM_LE_32(icondir->entries[c].bytes_in_res));
}
size += iconsize; /* size += FROM_LE_32(icondir->entries[c].bytes_in_res); */
@@ -419,7 +420,7 @@ byte *Win32ResExtractor::extract_group_icon_cursor_resource(WinLibrary *fi, WinR
fwr = find_resource(fi, (is_icon ? "-3" : "-1"), name, lang, &level);
if (fwr == NULL) {
error("%s: could not find `%s' in `%s' resource.",
- fi->file->name(), &name[1], (is_icon ? "group_icon" : "group_cursor"));
+ _fileName.c_str(), &name[1], (is_icon ? "group_icon" : "group_cursor"));
return NULL;
}
@@ -675,7 +676,7 @@ bool Win32ResExtractor::read_library(WinLibrary *fi) {
LE32(mz_header->lfanew);
if (mz_header->lfanew < sizeof(DOSImageHeader)) {
- error("%s: not a Windows library", fi->file->name());
+ error("%s: not a Windows library", _fileName.c_str());
return false;
}
}
@@ -724,7 +725,7 @@ bool Win32ResExtractor::read_library(WinLibrary *fi) {
RETURN_IF_BAD_POINTER(false, pe_header->optional_header.data_directory[IMAGE_DIRECTORY_ENTRY_RESOURCE]);
Win32ImageDataDirectory *dir = pe_header->optional_header.data_directory + IMAGE_DIRECTORY_ENTRY_RESOURCE;
if (dir->size == 0) {
- error("%s: file contains no resources", fi->file->name());
+ error("%s: file contains no resources", _fileName.c_str());
return false;
}
@@ -735,7 +736,7 @@ bool Win32ResExtractor::read_library(WinLibrary *fi) {
}
/* other (unknown) header signature was found */
- error("%s: not a Windows library", fi->file->name());
+ error("%s: not a Windows library", _fileName.c_str());
return false;
}
diff --git a/engines/scumm/he/resource_he.h b/engines/scumm/he/resource_he.h
index a3237e7b3b..9f4b423d3d 100644
--- a/engines/scumm/he/resource_he.h
+++ b/engines/scumm/he/resource_he.h
@@ -102,10 +102,10 @@ namespace Scumm {
#endif
#define RETURN_IF_BAD_POINTER(r, x) \
- if (!check_offset(fi->memory, fi->total_size, fi->file->name(), &(x), sizeof(x))) \
+ if (!check_offset(fi->memory, fi->total_size, _fileName.c_str(), &(x), sizeof(x))) \
return (r);
#define RETURN_IF_BAD_OFFSET(r, x, s) \
- if (!check_offset(fi->memory, fi->total_size, fi->file->name(), x, s)) \
+ if (!check_offset(fi->memory, fi->total_size, _fileName.c_str(), x, s)) \
return (r);
class ScummEngine_v70he;