[Scummvm-git-logs] scummvm master -> 5ee84a87ba0e4dd54f247f1555a85c913f03e4cf

sluicebox noreply at scummvm.org
Thu Apr 13 23:11:14 UTC 2023


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:
5ee84a87ba SCI: Fix memory leak in Audio::getAudioStream


Commit: 5ee84a87ba0e4dd54f247f1555a85c913f03e4cf
    https://github.com/scummvm/scummvm/commit/5ee84a87ba0e4dd54f247f1555a85c913f03e4cf
Author: sluicebox (22204938+sluicebox at users.noreply.github.com)
Date: 2023-04-13T16:04:46-07:00

Commit Message:
SCI: Fix memory leak in Audio::getAudioStream

Several codepaths leaked memoryStream and audioBuffer when encountering
compressed audio volumes. Unsupported compression types were only
correctly handled when no compression types were compiled in.

For example, if mp3 support was not compiled in but ogg or flac were,
then an mp3 volume would cause the audioBuffer and memoryStream to be
allocated and leaked with no error message.

Now, attempting an unsupported compression type is always an error.

Coverity issue 1457439

Changed paths:
    engines/sci/sound/audio.cpp
    engines/sci/sound/audio.h


diff --git a/engines/sci/sound/audio.cpp b/engines/sci/sound/audio.cpp
index 91044997512..21ec9b0cd18 100644
--- a/engines/sci/sound/audio.cpp
+++ b/engines/sci/sound/audio.cpp
@@ -399,30 +399,27 @@ Audio::RewindableAudioStream *AudioPlayer::getAudioStream(uint32 number, uint32
 	uint32 audioCompressionType = audioRes->getAudioCompressionType();
 
 	if (audioCompressionType) {
-#if (defined(USE_MAD) || defined(USE_VORBIS) || defined(USE_FLAC))
 		// Compressed audio made by our tool
 		switch (audioCompressionType) {
-		case MKTAG('M','P','3',' '):
 #ifdef USE_MAD
+		case MKTAG('M','P','3',' '):
 			audioSeekStream = Audio::makeMP3Stream(memoryStream, DisposeAfterUse::YES);
-#endif
 			break;
-		case MKTAG('O','G','G',' '):
+#endif
 #ifdef USE_VORBIS
+		case MKTAG('O','G','G',' '):
 			audioSeekStream = Audio::makeVorbisStream(memoryStream, DisposeAfterUse::YES);
-#endif
 			break;
-		case MKTAG('F','L','A','C'):
+#endif
 #ifdef USE_FLAC
+		case MKTAG('F','L','A','C'):
 			audioSeekStream = Audio::makeFLACStream(memoryStream, DisposeAfterUse::YES);
-#endif
 			break;
+#endif
 		default:
+			error("Compressed audio file encountered, but no decoder compiled in for: '%s'", tag2str(audioCompressionType));
 			break;
 		}
-#else
-		error("Compressed audio file encountered, but no appropriate decoder is compiled in");
-#endif
 	} else {
 		// Original source file
 		if (audioRes->size() > 6 &&
diff --git a/engines/sci/sound/audio.h b/engines/sci/sound/audio.h
index 787cffb7324..30333eeab1d 100644
--- a/engines/sci/sound/audio.h
+++ b/engines/sci/sound/audio.h
@@ -92,4 +92,4 @@ private:
 
 } // End of namespace Sci
 
-#endif // SCI_SFX_CORE_H
+#endif // SCI_AUDIO_H




More information about the Scummvm-git-logs mailing list