[Scummvm-git-logs] scummvm master -> 5140438d6073010b9c79793c5cfd43c56769e474
sluicebox
noreply at scummvm.org
Mon Oct 30 18:33:28 UTC 2023
This automated email contains information about 18 new commits which have been
pushed to the 'scummvm' repo located at https://github.com/scummvm/scummvm .
Summary:
8ba3a70961 COMMON: Fix memory leak in MidiDriver. PVS-Studio V773
d76c06e648 GUI: Fix memory leak in DownloadPacksDialog. PVS-Studio V773
0446cac990 IMAGE: Fix memory leak in Cel3DODecoder on error. PVS-Studio V773
86dc5c6453 ACCESS: Fix memory leak in playMovie. PVS-Studio V773
b1f466fb8e AGOS: Fix memory leaks. PVS-Studio V773
42513cff3f DIRECTOR: Fix memory leak in FileExists. PVS-Studio V773
220d8f696a DIRECTOR: Fix memory leak on QuickTime error. PVS-Studio V773
55c161140c DIRECTOR: Fix memory leak in font test. PVS-Studio V773
595df71332 GOB: Fix memory leak on error. PVS-Studio V773
a2db643088 HYPNO: Fix memory leak in loadPalette. PVS-Studio V773
71c6a0773b LAB: Fix memory leak on error. PVS-Studio V773
53675d9ef2 NANCY: Fix memory leak in console command. PVS-Studio V773
ff49bb84c4 NEVERHOOD: Fix memory leaks on error. PVS-Studio V773
e7eb740c55 SAGA: Fix memory leaks on error: PVS-Studio V773
47d51e54cd SHERLOCK: Fix memory leaks. PVS-Studio V773
fc32df7533 SLUDGE: Fix memory leak on error. PVS-Studio V773
fa82075d8d TESTBED: Fix memory leak on error. PVS-Studio V773
5140438d60 TRECISION: Fix memory leaks. PVS-Studio V773
Commit: 8ba3a709618e733c197dcebb224ff701fa8bb5ea
https://github.com/scummvm/scummvm/commit/8ba3a709618e733c197dcebb224ff701fa8bb5ea
Author: sluicebox (22204938+sluicebox at users.noreply.github.com)
Date: 2023-10-30T11:22:10-07:00
Commit Message:
COMMON: Fix memory leak in MidiDriver. PVS-Studio V773
Changed paths:
audio/mididrv.cpp
diff --git a/audio/mididrv.cpp b/audio/mididrv.cpp
index 1ae51447b00..ad09a293dde 100644
--- a/audio/mididrv.cpp
+++ b/audio/mididrv.cpp
@@ -523,19 +523,19 @@ void MidiDriver_BASE::midiDumpSysEx(const byte *msg, uint16 length) {
void MidiDriver_BASE::midiDumpFinish() {
- Common::DumpFile *midiDumpFile = new Common::DumpFile();
- midiDumpFile->open("dump.mid");
- midiDumpFile->write("MThd\0\0\0\x6\0\x1\0\x2", 12); // standard MIDI file header, with two tracks
- midiDumpFile->write("\x1\xf4", 2); // division - 500 ticks per beat, i.e. a quarter note. Each tick is 1ms
- midiDumpFile->write("MTrk", 4); // start of first track - doesn't contain real data, it's just common practice to use two tracks
- midiDumpFile->writeUint32BE(4); // first track size
- midiDumpFile->write("\0\xff\x2f\0", 4); // meta event - end of track
- midiDumpFile->write("MTrk", 4); // start of second track
- midiDumpFile->writeUint32BE(_midiDumpCache.size() + 4); // track size (+4 because of the 'end of track' event)
- midiDumpFile->write(_midiDumpCache.data(), _midiDumpCache.size());
- midiDumpFile->write("\0\xff\x2f\0", 4); // meta event - end of track
- midiDumpFile->finalize();
- midiDumpFile->close();
+ Common::DumpFile midiDumpFile;
+ midiDumpFile.open("dump.mid");
+ midiDumpFile.write("MThd\0\0\0\x6\0\x1\0\x2", 12); // standard MIDI file header, with two tracks
+ midiDumpFile.write("\x1\xf4", 2); // division - 500 ticks per beat, i.e. a quarter note. Each tick is 1ms
+ midiDumpFile.write("MTrk", 4); // start of first track - doesn't contain real data, it's just common practice to use two tracks
+ midiDumpFile.writeUint32BE(4); // first track size
+ midiDumpFile.write("\0\xff\x2f\0", 4); // meta event - end of track
+ midiDumpFile.write("MTrk", 4); // start of second track
+ midiDumpFile.writeUint32BE(_midiDumpCache.size() + 4); // track size (+4 because of the 'end of track' event)
+ midiDumpFile.write(_midiDumpCache.data(), _midiDumpCache.size());
+ midiDumpFile.write("\0\xff\x2f\0", 4); // meta event - end of track
+ midiDumpFile.finalize();
+ midiDumpFile.close();
const char msg[] = "Ending MIDI dump, created 'dump.mid'";
g_system->displayMessageOnOSD(_(msg)); //TODO: why it doesn't appear?
debug("%s", msg);
Commit: d76c06e6483252a339a76a57ef296905f25cceaf
https://github.com/scummvm/scummvm/commit/d76c06e6483252a339a76a57ef296905f25cceaf
Author: sluicebox (22204938+sluicebox at users.noreply.github.com)
Date: 2023-10-30T11:28:13-07:00
Commit Message:
GUI: Fix memory leak in DownloadPacksDialog. PVS-Studio V773
Changed paths:
gui/downloadpacksdialog.cpp
diff --git a/gui/downloadpacksdialog.cpp b/gui/downloadpacksdialog.cpp
index 962ee27ffe6..66f445e815b 100644
--- a/gui/downloadpacksdialog.cpp
+++ b/gui/downloadpacksdialog.cpp
@@ -398,11 +398,11 @@ void DownloadPacksDialog::calculateList() {
// Scan all files in iconspath and remove present and incomplete ones from the
// donwloaded files list
- Common::FSDirectory *iconDir = new Common::FSDirectory(iconsPath);
+ Common::FSDirectory iconDir(iconsPath);
Common::ArchiveMemberList iconFiles;
- iconDir->listMatchingMembers(iconFiles, _packsglob);
+ iconDir.listMatchingMembers(iconFiles, _packsglob);
for (auto ic = iconFiles.begin(); ic != iconFiles.end(); ++ic) {
Common::String fname = (*ic)->getName();
@@ -414,8 +414,6 @@ void DownloadPacksDialog::calculateList() {
g_state->fileHash.erase(fname);
}
- delete iconDir;
-
// Now calculate the size of the missing files
g_state->totalSize = 0;
for (auto f = g_state->fileHash.begin(); f != g_state->fileHash.end(); ++f) {
@@ -443,11 +441,11 @@ void DownloadPacksDialog::clearCache() {
return;
}
- Common::FSDirectory *iconDir = new Common::FSDirectory(iconsPath);
+ Common::FSDirectory iconDir(iconsPath);
Common::ArchiveMemberList iconFiles;
- iconDir->listMatchingMembers(iconFiles, _packsglob);
+ iconDir.listMatchingMembers(iconFiles, _packsglob);
int totalSize = 0;
for (auto ic = iconFiles.begin(); ic != iconFiles.end(); ++ic) {
Commit: 0446cac99059a1a43ba0d1396e5b27a3c5253f47
https://github.com/scummvm/scummvm/commit/0446cac99059a1a43ba0d1396e5b27a3c5253f47
Author: sluicebox (22204938+sluicebox at users.noreply.github.com)
Date: 2023-10-30T11:28:13-07:00
Commit Message:
IMAGE: Fix memory leak in Cel3DODecoder on error. PVS-Studio V773
Changed paths:
image/cel_3do.cpp
diff --git a/image/cel_3do.cpp b/image/cel_3do.cpp
index 7922c447ae6..12c6cda0699 100644
--- a/image/cel_3do.cpp
+++ b/image/cel_3do.cpp
@@ -108,8 +108,10 @@ bool Cel3DODecoder::loadStream(Common::SeekableReadStream &stream) {
}
// Only RGB555 is supported
- if ((pre0 & 0x17) != 0x16)
+ if ((pre0 & 0x17) != 0x16) {
+ delete surface;
return false;
+ }
if(!(flags & kCCBPacked)) {
// RAW
Commit: 86dc5c6453052205b5822f72e7c0c1475d58c489
https://github.com/scummvm/scummvm/commit/86dc5c6453052205b5822f72e7c0c1475d58c489
Author: sluicebox (22204938+sluicebox at users.noreply.github.com)
Date: 2023-10-30T11:28:13-07:00
Commit Message:
ACCESS: Fix memory leak in playMovie. PVS-Studio V773
Changed paths:
engines/access/video/movie_decoder.cpp
diff --git a/engines/access/video/movie_decoder.cpp b/engines/access/video/movie_decoder.cpp
index 64cb8ffb4bb..b22788fa445 100644
--- a/engines/access/video/movie_decoder.cpp
+++ b/engines/access/video/movie_decoder.cpp
@@ -693,11 +693,11 @@ Audio::AudioStream *AccessVIDMovieDecoder::StreamAudioTrack::getAudioStream() co
}
bool AccessEngine::playMovie(const Common::String &filename, const Common::Point &pos) {
- AccessVIDMovieDecoder *videoDecoder = new AccessVIDMovieDecoder();
+ AccessVIDMovieDecoder videoDecoder;
Common::Point framePos(pos.x, pos.y);
- if (!videoDecoder->loadFile(filename)) {
+ if (!videoDecoder.loadFile(filename)) {
warning("AccessVIDMoviePlay: could not open '%s'", filename.c_str());
return false;
}
@@ -705,17 +705,17 @@ bool AccessEngine::playMovie(const Common::String &filename, const Common::Point
bool skipVideo = false;
_events->clearEvents();
- videoDecoder->start();
+ videoDecoder.start();
- while (!shouldQuit() && !videoDecoder->endOfVideo() && !skipVideo) {
- if (videoDecoder->needsUpdate()) {
- const Graphics::Surface *frame = videoDecoder->decodeNextFrame();
+ while (!shouldQuit() && !videoDecoder.endOfVideo() && !skipVideo) {
+ if (videoDecoder.needsUpdate()) {
+ const Graphics::Surface *frame = videoDecoder.decodeNextFrame();
if (frame) {
_screen->blitFrom(*frame);
- if (videoDecoder->hasDirtyPalette()) {
- const byte *palette = videoDecoder->getPalette();
+ if (videoDecoder.hasDirtyPalette()) {
+ const byte *palette = videoDecoder.getPalette();
g_system->getPaletteManager()->setPalette(palette, 0, 256);
}
@@ -732,9 +732,6 @@ bool AccessEngine::playMovie(const Common::String &filename, const Common::Point
}
}
- videoDecoder->close();
- delete videoDecoder;
-
return !skipVideo;
}
Commit: b1f466fb8ec29d100fb00e43326f9933f037444b
https://github.com/scummvm/scummvm/commit/b1f466fb8ec29d100fb00e43326f9933f037444b
Author: sluicebox (22204938+sluicebox at users.noreply.github.com)
Date: 2023-10-30T11:28:14-07:00
Commit Message:
AGOS: Fix memory leaks. PVS-Studio V773
Changed paths:
engines/agos/sound.cpp
diff --git a/engines/agos/sound.cpp b/engines/agos/sound.cpp
index 69b0a2b1e67..eb2f60e3182 100644
--- a/engines/agos/sound.cpp
+++ b/engines/agos/sound.cpp
@@ -114,6 +114,7 @@ Common::SeekableReadStream *BaseSound::getSoundStream(uint sound) const {
Common::File *file = new Common::File();
if (!file->open(_filename)) {
warning("BaseSound::getSoundStream: Could not open file \"%s\"", _filename.c_str());
+ delete file;
return nullptr;
}
@@ -239,6 +240,7 @@ Audio::RewindableAudioStream *RawSound::makeAudioStream(uint sound) {
Common::File *file = new Common::File();
if (!file->open(_filename)) {
warning("RawSound::makeAudioStream: Could not open file \"%s\"", _filename.c_str());
+ delete file;
return nullptr;
}
Commit: 42513cff3fe7825a14c7437eba0023d17305ad37
https://github.com/scummvm/scummvm/commit/42513cff3fe7825a14c7437eba0023d17305ad37
Author: sluicebox (22204938+sluicebox at users.noreply.github.com)
Date: 2023-10-30T11:28:14-07:00
Commit Message:
DIRECTOR: Fix memory leak in FileExists. PVS-Studio V773
Changed paths:
engines/director/lingo/xlibs/fileexists.cpp
diff --git a/engines/director/lingo/xlibs/fileexists.cpp b/engines/director/lingo/xlibs/fileexists.cpp
index 602f2f7a87c..5f724c18492 100644
--- a/engines/director/lingo/xlibs/fileexists.cpp
+++ b/engines/director/lingo/xlibs/fileexists.cpp
@@ -72,9 +72,9 @@ void FileExists::m_fileexists(int nargs) {
}
Common::String filename = lastPathComponent(path, g_director->_dirSeparator);
if (!(saves->exists(filename))) {
- Common::File *f = new Common::File;
+ Common::File file;
Common::Path location = findPath(origpath);
- if (location.empty() || !f->open(location)) {
+ if (location.empty() || !file.open(location)) {
g_lingo->push(Datum(false));
return;
}
Commit: 220d8f696a6bd9ea1c47cb20e185837ada8c6262
https://github.com/scummvm/scummvm/commit/220d8f696a6bd9ea1c47cb20e185837ada8c6262
Author: sluicebox (22204938+sluicebox at users.noreply.github.com)
Date: 2023-10-30T11:28:14-07:00
Commit Message:
DIRECTOR: Fix memory leak on QuickTime error. PVS-Studio V773
Changed paths:
engines/director/lingo/xlibs/quicktime.cpp
diff --git a/engines/director/lingo/xlibs/quicktime.cpp b/engines/director/lingo/xlibs/quicktime.cpp
index 49de9ae5664..67295524ec8 100644
--- a/engines/director/lingo/xlibs/quicktime.cpp
+++ b/engines/director/lingo/xlibs/quicktime.cpp
@@ -79,6 +79,7 @@ void Quicktime::m_playStage(int nargs) {
Video::QuickTimeDecoder *video = new Video::QuickTimeDecoder();
if (!video->loadFile(filePath)) {
+ delete video;
g_lingo->push(Datum());
return;
}
Commit: 55c161140c560086ac5e9faf2cce9b996ecabdd1
https://github.com/scummvm/scummvm/commit/55c161140c560086ac5e9faf2cce9b996ecabdd1
Author: sluicebox (22204938+sluicebox at users.noreply.github.com)
Date: 2023-10-30T11:28:14-07:00
Commit Message:
DIRECTOR: Fix memory leak in font test. PVS-Studio V773
Changed paths:
engines/director/tests.cpp
diff --git a/engines/director/tests.cpp b/engines/director/tests.cpp
index d3785d24dee..320d09119fd 100644
--- a/engines/director/tests.cpp
+++ b/engines/director/tests.cpp
@@ -116,10 +116,10 @@ void Window::testFontScaling() {
in.open(path);
if (in.isOpen()) {
- Image::PICTDecoder *k = new Image::PICTDecoder();
- k->loadStream(in);
+ Image::PICTDecoder k;
+ k.loadStream(in);
- Graphics::Surface *res = k->getSurface()->convertTo(_wm->_pixelformat, k->getPalette(), k->getPaletteSize(), _wm->getPalette(), _wm->getPaletteSize(), Graphics::kDitherNaive);
+ Graphics::Surface *res = k.getSurface()->convertTo(_wm->_pixelformat, k.getPalette(), k.getPaletteSize(), _wm->getPalette(), _wm->getPaletteSize(), Graphics::kDitherNaive);
surface.blitFrom(res, Common::Point(400, 280));
in.close();
Commit: 595df7133222693847b607fa35af4e33122a1652
https://github.com/scummvm/scummvm/commit/595df7133222693847b607fa35af4e33122a1652
Author: sluicebox (22204938+sluicebox at users.noreply.github.com)
Date: 2023-10-30T11:28:14-07:00
Commit Message:
GOB: Fix memory leak on error. PVS-Studio V773
Changed paths:
engines/gob/save/saveconverter.cpp
diff --git a/engines/gob/save/saveconverter.cpp b/engines/gob/save/saveconverter.cpp
index 9d5925ea7cf..c75af7039e6 100644
--- a/engines/gob/save/saveconverter.cpp
+++ b/engines/gob/save/saveconverter.cpp
@@ -278,8 +278,10 @@ SavePartSprite *SaveConverter::readSprite(Common::SeekableReadStream &stream,
delete[] data;
if (palette)
- if (!sprite->readPalette(pal))
+ if (!sprite->readPalette(pal)) {
+ delete sprite;
return nullptr;
+ }
return sprite;
}
Commit: a2db64308879f76695d19a39907770a256a20a52
https://github.com/scummvm/scummvm/commit/a2db64308879f76695d19a39907770a256a20a52
Author: sluicebox (22204938+sluicebox at users.noreply.github.com)
Date: 2023-10-30T11:28:14-07:00
Commit Message:
HYPNO: Fix memory leak in loadPalette. PVS-Studio V773
Changed paths:
engines/hypno/hypno.cpp
diff --git a/engines/hypno/hypno.cpp b/engines/hypno/hypno.cpp
index 5edc9d6b726..1930a020e74 100644
--- a/engines/hypno/hypno.cpp
+++ b/engines/hypno/hypno.cpp
@@ -422,17 +422,17 @@ void HypnoEngine::changeScreenMode(const Common::String &mode) {
}
void HypnoEngine::loadPalette(const Common::String &fname) {
- Common::File *file = new Common::File();
+ Common::File file;
Common::String path = convertPath(fname);
if (!_prefixDir.empty())
path = _prefixDir + "/" + path;
- if (!file->open(path))
+ if (!file.open(path))
error("unable to find palette file %s", path.c_str());
debugC(1, kHypnoDebugMedia, "Loading palette from %s", path.c_str());
- byte *videoPalette = (byte *)malloc(file->size());
- file->read(videoPalette, file->size());
+ byte *videoPalette = (byte *)malloc(file.size());
+ file.read(videoPalette, file.size());
g_system->getPaletteManager()->setPalette(videoPalette + 8, 0, 256);
}
Commit: 71c6a0773b1c2ad698404822c9daaf3584070070
https://github.com/scummvm/scummvm/commit/71c6a0773b1c2ad698404822c9daaf3584070070
Author: sluicebox (22204938+sluicebox at users.noreply.github.com)
Date: 2023-10-30T11:28:14-07:00
Commit Message:
LAB: Fix memory leak on error. PVS-Studio V773
Changed paths:
engines/lab/resource.cpp
diff --git a/engines/lab/resource.cpp b/engines/lab/resource.cpp
index 9daffe102d1..2ba6206ce61 100644
--- a/engines/lab/resource.cpp
+++ b/engines/lab/resource.cpp
@@ -224,6 +224,7 @@ Common::File *Resource::openDataFile(const Common::String filename, uint32 fileH
// The DOS version is known to have some missing files
if (_vm->getPlatform() == Common::kPlatformDOS) {
warning("Incomplete DOS version, skipping file %s", filename.c_str());
+ delete dataFile;
return nullptr;
} else
error("openDataFile: Couldn't open %s (%s)", translateFileName(filename).c_str(), filename.c_str());
Commit: 53675d9ef2dca5018c9290481fae6474b3310931
https://github.com/scummvm/scummvm/commit/53675d9ef2dca5018c9290481fae6474b3310931
Author: sluicebox (22204938+sluicebox at users.noreply.github.com)
Date: 2023-10-30T11:28:14-07:00
Commit Message:
NANCY: Fix memory leak in console command. PVS-Studio V773
Changed paths:
engines/nancy/console.cpp
diff --git a/engines/nancy/console.cpp b/engines/nancy/console.cpp
index 1795f3c46d9..5b7ee6e5a11 100644
--- a/engines/nancy/console.cpp
+++ b/engines/nancy/console.cpp
@@ -414,6 +414,7 @@ bool NancyConsole::Cmd_playSound(int argc, const char **argv) {
Common::File *f = new Common::File;
if (!f->open(Common::String(argv[1]) + ".his")) {
debugPrintf("Failed to open '%s.his'\n", argv[1]);
+ delete f;
return true;
}
Commit: ff49bb84c47c7d91352924f4949fb2e7326c3189
https://github.com/scummvm/scummvm/commit/ff49bb84c47c7d91352924f4949fb2e7326c3189
Author: sluicebox (22204938+sluicebox at users.noreply.github.com)
Date: 2023-10-30T11:28:14-07:00
Commit Message:
NEVERHOOD: Fix memory leaks on error. PVS-Studio V773
Changed paths:
engines/neverhood/resourceman.cpp
diff --git a/engines/neverhood/resourceman.cpp b/engines/neverhood/resourceman.cpp
index 1e755bada0b..e4c727d1a0c 100644
--- a/engines/neverhood/resourceman.cpp
+++ b/engines/neverhood/resourceman.cpp
@@ -38,8 +38,10 @@ ResourceMan::~ResourceMan() {
void ResourceMan::addArchive(const Common::String &filename, bool isOptional) {
BlbArchive *archive = new BlbArchive();
- if (!archive->open(filename, isOptional))
+ if (!archive->open(filename, isOptional)) {
+ delete archive;
return;
+ }
_archives.push_back(archive);
debug(3, "ResourceMan::addArchive(%s) %d files", filename.c_str(), archive->getCount());
for (uint archiveEntryIndex = 0; archiveEntryIndex < archive->getCount(); archiveEntryIndex++) {
@@ -64,8 +66,10 @@ void ResourceMan::addArchive(const Common::String &filename, bool isOptional) {
bool ResourceMan::addNhcArchive(const Common::String &filename) {
NhcArchive *archive = new NhcArchive();
- if (!archive->open(filename, true))
+ if (!archive->open(filename, true)) {
+ delete archive;
return false;
+ }
_nhcArchives.push_back(archive);
debug(3, "ResourceMan::addArchive(%s) %d files", filename.c_str(), archive->getCount());
for (uint archiveEntryIndex = 0; archiveEntryIndex < archive->getCount(); archiveEntryIndex++) {
Commit: e7eb740c55d63698525815ada88dcc2adcc1b61b
https://github.com/scummvm/scummvm/commit/e7eb740c55d63698525815ada88dcc2adcc1b61b
Author: sluicebox (22204938+sluicebox at users.noreply.github.com)
Date: 2023-10-30T11:28:14-07:00
Commit Message:
SAGA: Fix memory leaks on error: PVS-Studio V773
Changed paths:
engines/saga/animation.cpp
diff --git a/engines/saga/animation.cpp b/engines/saga/animation.cpp
index 54a6bdc2bc5..a13d8bae3b7 100644
--- a/engines/saga/animation.cpp
+++ b/engines/saga/animation.cpp
@@ -386,12 +386,14 @@ void Anim::load(uint16 animId, const ByteArray &resourceData) {
anim->magic = headerReadS.readUint16LE(); // cause ALWAYS LE
if (anim->magic != 0x0044) {
warning ("Anim::load animId=%d animation magic mismatch (0x%x vs 0x%x), skipping", animId, anim->magic, 0x0044);
+ delete anim;
return;
}
anim->screenWidth = headerReadS.readUint16();
anim->screenHeight = headerReadS.readUint16();
if (anim->screenHeight > 2000 || anim->screenWidth > 2000) {
warning ("Anim::load animId=%d Excessive dimensions %dx%d, skipping", animId, anim->screenWidth, anim->screenHeight);
+ delete anim;
return;
}
Commit: 47d51e54cd9a0130950176e0b53391d613748c21
https://github.com/scummvm/scummvm/commit/47d51e54cd9a0130950176e0b53391d613748c21
Author: sluicebox (22204938+sluicebox at users.noreply.github.com)
Date: 2023-10-30T11:28:14-07:00
Commit Message:
SHERLOCK: Fix memory leaks. PVS-Studio V773
Changed paths:
engines/sherlock/animation.cpp
engines/sherlock/music.cpp
engines/sherlock/scalpel/scalpel_debugger.cpp
diff --git a/engines/sherlock/animation.cpp b/engines/sherlock/animation.cpp
index 1d33f5fdec2..0df6fe9f136 100644
--- a/engines/sherlock/animation.cpp
+++ b/engines/sherlock/animation.cpp
@@ -162,9 +162,8 @@ bool Animation::play3DO(const Common::String &filename, bool intro, int minDelay
Common::String indexName = "prologue/" + filename + ".3dx";
// Load the animation
- Common::File *indexStream = new Common::File();
-
- if (!indexStream->open(indexName)) {
+ Common::File indexStream;
+ if (!indexStream.open(indexName)) {
warning("unable to open %s\n", indexName.c_str());
return false;
}
@@ -185,7 +184,7 @@ bool Animation::play3DO(const Common::String &filename, bool intro, int minDelay
bool skipped = false;
while (!_vm->shouldQuit()) {
// Get the next sprite to display
- int imageFrame = indexStream->readSint16BE();
+ int imageFrame = indexStream.readSint16BE();
if (imageFrame == -2) {
// End of animation reached
@@ -194,8 +193,8 @@ bool Animation::play3DO(const Common::String &filename, bool intro, int minDelay
// Read position from either animation stream or the sprite frame itself
if (imageFrame < 0) {
imageFrame += 32768;
- pt.x = indexStream->readUint16BE();
- pt.y = indexStream->readUint16BE();
+ pt.x = indexStream.readUint16BE();
+ pt.y = indexStream.readUint16BE();
} else {
pt = images[imageFrame]._offset;
}
@@ -261,7 +260,6 @@ bool Animation::play3DO(const Common::String &filename, bool intro, int minDelay
events.clearEvents();
sound.stopSound();
- delete indexStream;
return !skipped && !_vm->shouldQuit();
}
diff --git a/engines/sherlock/music.cpp b/engines/sherlock/music.cpp
index fcddea6aa38..022629131ab 100644
--- a/engines/sherlock/music.cpp
+++ b/engines/sherlock/music.cpp
@@ -485,6 +485,7 @@ bool Music::playMusic(const Common::String &name) {
Common::File *digitalMusicFile = new Common::File();
if (!digitalMusicFile->open(digitalMusicName)) {
warning("playMusic: can not open 3DO music '%s'", digitalMusicName.c_str());
+ delete digitalMusicFile;
return false;
}
diff --git a/engines/sherlock/scalpel/scalpel_debugger.cpp b/engines/sherlock/scalpel/scalpel_debugger.cpp
index 9017dd48918..d410d333eb0 100644
--- a/engines/sherlock/scalpel/scalpel_debugger.cpp
+++ b/engines/sherlock/scalpel/scalpel_debugger.cpp
@@ -56,6 +56,7 @@ bool ScalpelDebugger::cmd3DO_PlayAudio(int argc, const char **argv) {
Common::File *file = new Common::File();
if (!file->open(argv[1])) {
debugPrintf("can not open specified audio file\n");
+ delete file;
return true;
}
Commit: fc32df75330fd11406b9f39a8a67e7d9b317b1c2
https://github.com/scummvm/scummvm/commit/fc32df75330fd11406b9f39a8a67e7d9b317b1c2
Author: sluicebox (22204938+sluicebox at users.noreply.github.com)
Date: 2023-10-30T11:28:14-07:00
Commit Message:
SLUDGE: Fix memory leak on error. PVS-Studio V773
Changed paths:
engines/sludge/sludger.cpp
diff --git a/engines/sludge/sludger.cpp b/engines/sludge/sludger.cpp
index 4dcf1c75acd..1290ddb8ded 100644
--- a/engines/sludge/sludger.cpp
+++ b/engines/sludge/sludger.cpp
@@ -176,8 +176,10 @@ bool initSludge(const Common::String &filename) {
numBIFNames = fp->readUint16BE();
debugC(2, kSludgeDebugDataLoad, "numBIFNames %i", numBIFNames);
allBIFNames = new Common::String[numBIFNames];
- if (!checkNew(allBIFNames))
+ if (!checkNew(allBIFNames)) {
+ delete fp;
return false;
+ }
for (int fn = 0; fn < numBIFNames; fn++) {
allBIFNames[fn].clear();
@@ -186,8 +188,10 @@ bool initSludge(const Common::String &filename) {
numUserFunc = fp->readUint16BE();
debugC(2, kSludgeDebugDataLoad, "numUserFunc %i", numUserFunc);
allUserFunc = new Common::String[numUserFunc];
- if (!checkNew(allUserFunc))
+ if (!checkNew(allUserFunc)) {
+ delete fp;
return false;
+ }
for (int fn = 0; fn < numUserFunc; fn++) {
allUserFunc[fn].clear();
@@ -244,9 +248,10 @@ bool initSludge(const Common::String &filename) {
// read game icon
Graphics::Surface gameIcon;
- if (!ImgLoader::loadImage(-1, "icon", fp, &gameIcon, false))
+ if (!ImgLoader::loadImage(-1, "icon", fp, &gameIcon, false)) {
+ delete fp;
return false;
-
+ }
}
if (customIconLogo & 2) {
@@ -255,16 +260,20 @@ bool initSludge(const Common::String &filename) {
// read game logo
Graphics::Surface gameLogo;
- if (!ImgLoader::loadImage(-1, "logo", fp, &gameLogo))
+ if (!ImgLoader::loadImage(-1, "logo", fp, &gameLogo)) {
+ delete fp;
return false;
+ }
}
numGlobals = fp->readUint16BE();
debugC(2, kSludgeDebugDataLoad, "numGlobals : %i", numGlobals);
globalVars = new Variable[numGlobals];
- if (!checkNew(globalVars))
+ if (!checkNew(globalVars)) {
+ delete fp;
return false;
+ }
// Get language selected by user
g_sludge->_resMan->setData(fp);
Commit: fa82075d8d95182b027c1174cad8d58fbd7dacc4
https://github.com/scummvm/scummvm/commit/fa82075d8d95182b027c1174cad8d58fbd7dacc4
Author: sluicebox (22204938+sluicebox at users.noreply.github.com)
Date: 2023-10-30T11:28:14-07:00
Commit Message:
TESTBED: Fix memory leak on error. PVS-Studio V773
Changed paths:
engines/testbed/video.cpp
diff --git a/engines/testbed/video.cpp b/engines/testbed/video.cpp
index da349e051c1..3aed6695e3e 100644
--- a/engines/testbed/video.cpp
+++ b/engines/testbed/video.cpp
@@ -36,6 +36,7 @@ Common::Error Videotests::videoTest(const Common::Path &path) {
Common::File *file = new Common::File();
if (!file->open(path)) {
warning("Cannot open file %s", path.toString().c_str());
+ delete file;
return Common::kNoGameDataFoundError;
}
return videoTest(file, path.toString());
Commit: 5140438d6073010b9c79793c5cfd43c56769e474
https://github.com/scummvm/scummvm/commit/5140438d6073010b9c79793c5cfd43c56769e474
Author: sluicebox (22204938+sluicebox at users.noreply.github.com)
Date: 2023-10-30T11:28:14-07:00
Commit Message:
TRECISION: Fix memory leaks. PVS-Studio V773
Changed paths:
engines/trecision/console.cpp
engines/trecision/video.cpp
diff --git a/engines/trecision/console.cpp b/engines/trecision/console.cpp
index f7729af3b87..5c4a495db16 100644
--- a/engines/trecision/console.cpp
+++ b/engines/trecision/console.cpp
@@ -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;
}
diff --git a/engines/trecision/video.cpp b/engines/trecision/video.cpp
index 4951dbf16fb..2e3b74c4855 100644
--- a/engines/trecision/video.cpp
+++ b/engines/trecision/video.cpp
@@ -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
More information about the Scummvm-git-logs
mailing list