[Scummvm-git-logs] scummvm master -> 5862c00048bb8f5299f42f202ec5206828eec8ad
sev-
noreply at scummvm.org
Mon Dec 9 15:05:14 UTC 2024
This automated email contains information about 1 new commit which have been
pushed to the 'scummvm' repo located at https://github.com/scummvm/scummvm .
Summary:
5862c00048 QDENGINE: Fix memory leaks when reading files
Commit: 5862c00048bb8f5299f42f202ec5206828eec8ad
https://github.com/scummvm/scummvm/commit/5862c00048bb8f5299f42f202ec5206828eec8ad
Author: Cameron Cawley (ccawley2011 at gmail.com)
Date: 2024-12-09T16:05:10+01:00
Commit Message:
QDENGINE: Fix memory leaks when reading files
Changed paths:
engines/qdengine/qdcore/qd_animation.cpp
engines/qdengine/qdcore/qd_font_info.cpp
engines/qdengine/qdcore/qd_sprite.cpp
engines/qdengine/qdcore/util/plaympp_api.cpp
engines/qdengine/qdcore/util/plaympp_api.h
engines/qdengine/system/sound/wav_sound.cpp
diff --git a/engines/qdengine/qdcore/qd_animation.cpp b/engines/qdengine/qdcore/qd_animation.cpp
index fbc23eb7306..055f2084c9a 100644
--- a/engines/qdengine/qdcore/qd_animation.cpp
+++ b/engines/qdengine/qdcore/qd_animation.cpp
@@ -704,6 +704,8 @@ bool qdAnimation::qda_load(Common::Path fpath) {
//_tileAnimation->dumpTiles(fpath, 50);
}
+ delete fh;
+
init_size();
return true;
diff --git a/engines/qdengine/qdcore/qd_font_info.cpp b/engines/qdengine/qdcore/qd_font_info.cpp
index 7af9abe2f35..5d7729edf3c 100644
--- a/engines/qdengine/qdcore/qd_font_info.cpp
+++ b/engines/qdengine/qdcore/qd_font_info.cpp
@@ -113,15 +113,18 @@ bool qdFontInfo::load_font() {
Common::replace(fpath, tgaExt, idxExt);
+ delete fh;
+ fh = nullptr;
+
// ÐÑкÑÑваем .idx и гÑÑзим индекÑ
if (qdFileManager::instance().open_file(&fh, Common::Path(fpath), false)) {
if (buf_font->load_index(fh))
load_fl = true;
}
}
- }
- delete fh;
+ delete fh;
+ }
if (!load_fl) {
delete buf_font;
diff --git a/engines/qdengine/qdcore/qd_sprite.cpp b/engines/qdengine/qdcore/qd_sprite.cpp
index b32e72f06b0..682ac39e0f9 100644
--- a/engines/qdengine/qdcore/qd_sprite.cpp
+++ b/engines/qdengine/qdcore/qd_sprite.cpp
@@ -243,6 +243,8 @@ bool qdSprite::load() {
Image::TGADecoder tgaDecoder;
tgaDecoder.loadStream(*fh);
+ delete fh;
+
const Graphics::Surface *tgaSurface = tgaDecoder.getSurface();
int width = _picture_size.x = tgaSurface->w; ///< width of the sprite. number of pixels in width
@@ -283,8 +285,6 @@ bool qdSprite::load() {
dataPtr += widthNB;
}
- delete fh;
-
const byte min_color = 8;
if (_format == GR_ARGB8888) {
for (int i = 0; i < _picture_size.x * _picture_size.y; i++) {
diff --git a/engines/qdengine/qdcore/util/plaympp_api.cpp b/engines/qdengine/qdcore/util/plaympp_api.cpp
index ece93b618ba..0eca2aa6336 100644
--- a/engines/qdengine/qdcore/util/plaympp_api.cpp
+++ b/engines/qdengine/qdcore/util/plaympp_api.cpp
@@ -52,19 +52,21 @@ bool mpegPlayer::play(const Common::Path file, bool loop, int vol) {
stop();
- if (qdFileManager::instance().open_file(&_stream, file, false)) {
+ Common::SeekableReadStream *stream;
+
+ if (qdFileManager::instance().open_file(&stream, file, false)) {
Audio::SeekableAudioStream *audiostream;
if (isOGG) {
#ifdef USE_VORBIS
- audiostream = Audio::makeVorbisStream(_stream, DisposeAfterUse::YES);
+ audiostream = Audio::makeVorbisStream(stream, DisposeAfterUse::YES);
#else
warning("mpegPlayer::play(%s, %d, %d): Vorbis support not compiled", file.toString().c_str(), loop, vol);
return false;
#endif
} else {
#ifdef USE_MPCDEC
- audiostream = Audio::makeMPCStream(_stream, DisposeAfterUse::YES);
+ audiostream = Audio::makeMPCStream(stream, DisposeAfterUse::YES);
#else
warning("mpegPlayer::play(%s, %d, %d): MPC support not compiled", file.toString().c_str(), loop, vol);
return false;
diff --git a/engines/qdengine/qdcore/util/plaympp_api.h b/engines/qdengine/qdcore/util/plaympp_api.h
index bf7fbdf8041..034840f0c96 100644
--- a/engines/qdengine/qdcore/util/plaympp_api.h
+++ b/engines/qdengine/qdcore/util/plaympp_api.h
@@ -94,8 +94,6 @@ private:
Audio::SoundHandle _soundHandle;
- Common::SeekableReadStream *_stream = nullptr;
-
Common::Path _file;
};
diff --git a/engines/qdengine/system/sound/wav_sound.cpp b/engines/qdengine/system/sound/wav_sound.cpp
index 1ea436be86c..9c9af6ebdcb 100644
--- a/engines/qdengine/system/sound/wav_sound.cpp
+++ b/engines/qdengine/system/sound/wav_sound.cpp
@@ -51,13 +51,13 @@ bool wavSound::wav_file_load(const Common::Path fpath) {
if (qdFileManager::instance().open_file(&stream, fpath.toString().c_str(), false)) {
if (_fname.baseName().hasSuffixIgnoreCase(".ogg")) {
#ifdef USE_VORBIS
- _audioStream = Audio::makeVorbisStream(stream, DisposeAfterUse::NO);
+ _audioStream = Audio::makeVorbisStream(stream, DisposeAfterUse::YES);
#else
warning("wavSound::wav_file_load(%s): Vorbis support not compiled", fpath.toString().c_str());
return false;
#endif
} else {
- _audioStream = Audio::makeWAVStream(stream, DisposeAfterUse::NO);
+ _audioStream = Audio::makeWAVStream(stream, DisposeAfterUse::YES);
}
_length = (float)_audioStream->getLength().msecs() / 1000.0;
More information about the Scummvm-git-logs
mailing list