DIRECTOR: Fix use-after-free

This commit is contained in:
Vladimir Serbinenko 2023-05-07 03:23:07 +02:00 committed by Eugene Sandulenko
parent 8976c4f56b
commit 036297b605

View File

@ -570,6 +570,7 @@ bool RIFXArchive::openStream(Common::SeekableReadStream *stream, uint32 startOff
_isBigEndian = false;
} else {
warning("RIFXArchive::openStream(): RIFX or XFIR expected but %s found", tag2str(headerTag));
_stream = nullptr;
return false;
}
@ -641,8 +642,10 @@ bool RIFXArchive::openStream(Common::SeekableReadStream *stream, uint32 startOff
delete dumpStream;
// If we couldn't read the map, we can't do anything past this point.
if (!readMapSuccess)
if (!readMapSuccess) {
_stream = nullptr;
return false;
}
if (_rifxType == MKTAG('A', 'P', 'P', 'L')) {
if (hasResource(MKTAG('F', 'i', 'l', 'e'), -1)) {
@ -654,6 +657,7 @@ bool RIFXArchive::openStream(Common::SeekableReadStream *stream, uint32 startOff
return openStream(_stream, fileOffset);
} else {
warning("No 'File' resource present in APPL archive");
_stream = nullptr;
return false;
}
}