COMMON: Fix memory leak when invalid PE executable is loaded

In function `PEResources::loadFromEXE`, there were memory leaks
because of not properly handling with streams, and thus when the
loaded movie was bad/non-exe file, the memory was not freed.

This was undetected in normal exe loading because there the streams
were being assigned and closed properly.
This commit is contained in:
Harishankar Kumar 2023-06-13 17:59:20 +05:30 committed by Eugene Sandulenko
parent 2c570f27e5
commit 7d8dcebeb7
No known key found for this signature in database
GPG Key ID: 014D387312D34F08

View File

@ -49,6 +49,9 @@ void PEResources::clear() {
bool PEResources::loadFromEXE(SeekableReadStream *stream, DisposeAfterUse::Flag disposeFileHandle) {
clear();
_exe = stream;
_disposeFileHandle = disposeFileHandle;
if (!stream)
return false;
@ -95,9 +98,6 @@ bool PEResources::loadFromEXE(SeekableReadStream *stream, DisposeAfterUse::Flag
return false;
}
_exe = stream;
_disposeFileHandle = disposeFileHandle;
Section &resSection = _sections[".rsrc"];
parseResourceLevel(resSection, resSection.offset, 0);