TRECISION: Fix memory leaks. PVS-Studio V773

This commit is contained in:
sluicebox 2023-10-30 11:22:12 -07:00
parent fa82075d8d
commit 5140438d60
2 changed files with 13 additions and 11 deletions

View File

@ -87,12 +87,12 @@ bool Console::Cmd_DumpAnim(int argc, const char **argv) {
Common::SeekableReadStream *dataFile = animFile.createReadStreamForMember(fileName);
Common::DumpFile *outFile = new Common::DumpFile();
Common::DumpFile outFile;
Common::String outName = fileName + ".dump";
outFile->open(outName);
outFile->writeStream(dataFile, dataFile->size());
outFile->finalize();
outFile->close();
outFile.open(outName);
outFile.writeStream(dataFile, dataFile->size());
outFile.finalize();
outFile.close();
animFile.close();
@ -114,12 +114,12 @@ bool Console::Cmd_DumpFile(int argc, const char **argv) {
Common::SeekableReadStream *dataFile = fileName.hasSuffix(".cr") ? _vm->_dataFile.createReadStreamForCompressedMember(fileName) : _vm->_dataFile.createReadStreamForMember(fileName);
Common::DumpFile *outFile = new Common::DumpFile();
Common::DumpFile outFile;
Common::String outName = fileName + ".dump";
outFile->open(outName);
outFile->writeStream(dataFile, dataFile->size());
outFile->finalize();
outFile->close();
outFile.open(outName);
outFile.writeStream(dataFile, dataFile->size());
outFile.finalize();
outFile.close();
return true;
}

View File

@ -129,8 +129,10 @@ NightlongAmigaDecoder::AmigaVideoTrack::AmigaVideoTrack(const Common::String &fi
Common::File *stream = new Common::File();
stream->open(fileName);
if (!stream->isOpen())
if (!stream->isOpen()) {
delete stream;
return;
}
_curFrame = 0;
_frameCount = 10; // TODO: Anything > 1 to keep playing till the audio is done