Skip to content

Commit

Permalink
COMMON: Fix memory leak when invalid PE executable is loaded
Browse files Browse the repository at this point in the history
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.
  • Loading branch information
hari01584 authored and sev- committed Jun 14, 2023
1 parent 2c570f2 commit 7d8dceb
Showing 1 changed file with 3 additions and 3 deletions.
6 changes: 3 additions & 3 deletions common/formats/winexe_pe.cpp
Expand Up @@ -49,6 +49,9 @@ void PEResources::clear() {
bool PEResources::loadFromEXE(SeekableReadStream *stream, DisposeAfterUse::Flag disposeFileHandle) {
clear();

_exe = stream;
_disposeFileHandle = disposeFileHandle;

if (!stream)
return false;

Expand Down Expand Up @@ -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);

Expand Down

0 comments on commit 7d8dceb

Please sign in to comment.