[Scummvm-cvs-logs] SF.net SVN: scummvm:[34683] scummvm/trunk/engines/scumm/he
fingolfin at users.sourceforge.net
fingolfin at users.sourceforge.net
Mon Sep 29 13:02:13 CEST 2008
Revision: 34683
http://scummvm.svn.sourceforge.net/scummvm/?rev=34683&view=rev
Author: fingolfin
Date: 2008-09-29 11:02:11 +0000 (Mon, 29 Sep 2008)
Log Message:
-----------
SCUMM HE: Fixed leak in Win32ResExtractor::extractResource_, use _filename instead of File::name
Modified Paths:
--------------
scummvm/trunk/engines/scumm/he/resource_he.cpp
scummvm/trunk/engines/scumm/he/resource_he.h
Modified: scummvm/trunk/engines/scumm/he/resource_he.cpp
===================================================================
--- scummvm/trunk/engines/scumm/he/resource_he.cpp 2008-09-29 11:01:25 UTC (rev 34682)
+++ scummvm/trunk/engines/scumm/he/resource_he.cpp 2008-09-29 11:02:11 UTC (rev 34683)
@@ -165,7 +165,6 @@
_fileName = _vm->generateFilename(-3);
}
-
/* get file size */
fi.file->open(_fileName);
if (!fi.file->isOpen()) {
@@ -174,18 +173,18 @@
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 @@
/* 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 @@
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 @@
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 @@
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 @@
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 @@
}
/* 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;
}
Modified: scummvm/trunk/engines/scumm/he/resource_he.h
===================================================================
--- scummvm/trunk/engines/scumm/he/resource_he.h 2008-09-29 11:01:25 UTC (rev 34682)
+++ scummvm/trunk/engines/scumm/he/resource_he.h 2008-09-29 11:02:11 UTC (rev 34683)
@@ -102,10 +102,10 @@
#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;
This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site.
More information about the Scummvm-git-logs
mailing list