diff options
author | Sven Hesse | 2012-07-08 22:15:40 +0200 |
---|---|---|
committer | Sven Hesse | 2012-07-30 01:44:46 +0200 |
commit | 3189729c972b5da1356497e82e08a21c94c8fbec (patch) | |
tree | 5308295aa7825593f1c740b04beb2db8e8c2d43b /engines/gob/sound/sound.cpp | |
parent | 850472f21e73280c0bf35c76163419a7e280fea2 (diff) | |
download | scummvm-rg350-3189729c972b5da1356497e82e08a21c94c8fbec.tar.gz scummvm-rg350-3189729c972b5da1356497e82e08a21c94c8fbec.tar.bz2 scummvm-rg350-3189729c972b5da1356497e82e08a21c94c8fbec.zip |
GOB: Don't leak in sampleLoad() when loading fails
Diffstat (limited to 'engines/gob/sound/sound.cpp')
-rw-r--r-- | engines/gob/sound/sound.cpp | 11 |
1 files changed, 7 insertions, 4 deletions
diff --git a/engines/gob/sound/sound.cpp b/engines/gob/sound/sound.cpp index 69a668e5fb..63af6aeef4 100644 --- a/engines/gob/sound/sound.cpp +++ b/engines/gob/sound/sound.cpp @@ -109,7 +109,7 @@ int Sound::sampleGetNextFreeSlot() const { return -1; } -bool Sound::sampleLoad(SoundDesc *sndDesc, SoundType type, const char *fileName, bool tryExist) { +bool Sound::sampleLoad(SoundDesc *sndDesc, SoundType type, const char *fileName) { if (!sndDesc) return false; @@ -117,12 +117,15 @@ bool Sound::sampleLoad(SoundDesc *sndDesc, SoundType type, const char *fileName, int32 size; byte *data = _vm->_dataIO->getFile(fileName, size); - if (!data) { - warning("Can't open sample file \"%s\"", fileName); + + if (!data || !sndDesc->load(type, data, size)) { + delete data; + + warning("Sound::sampleLoad(): Failed to load sound \"%s\"", fileName); return false; } - return sndDesc->load(type, data, size); + return true; } void Sound::sampleFree(SoundDesc *sndDesc, bool noteAdLib, int index) { |