diff options
author | Johannes Schickel | 2010-05-03 13:03:44 +0000 |
---|---|---|
committer | Johannes Schickel | 2010-05-03 13:03:44 +0000 |
commit | f2ee496c0ead8812660385fe379bb005e0af0b3c (patch) | |
tree | 50c0b61f04f4278ab5e311e5d7a60cf24fefd2e6 | |
parent | df679afe19901500a5e704d2b11df5a7b25c5436 (diff) | |
download | scummvm-rg350-f2ee496c0ead8812660385fe379bb005e0af0b3c.tar.gz scummvm-rg350-f2ee496c0ead8812660385fe379bb005e0af0b3c.tar.bz2 scummvm-rg350-f2ee496c0ead8812660385fe379bb005e0af0b3c.zip |
Paranoia change: Prevent possible assertion caused by MP3Stream.
Currently we have an assert checking that the framerate of an
Audio::Timestamp is always > 0. Since MAD might return "0"
(and maybe even other illegal values) in case the MP3 stream is
invalid we need to check that before we setup the _length
Timestamp of MP3Stream.
svn-id: r48904
-rw-r--r-- | sound/decoders/mp3.cpp | 9 |
1 files changed, 8 insertions, 1 deletions
diff --git a/sound/decoders/mp3.cpp b/sound/decoders/mp3.cpp index 90642368a5..f66d6324ef 100644 --- a/sound/decoders/mp3.cpp +++ b/sound/decoders/mp3.cpp @@ -114,7 +114,14 @@ MP3Stream::MP3Stream(Common::SeekableReadStream *inStream, DisposeAfterUse::Flag while (_state != MP3_STATE_EOS) readHeader(); - _length = Timestamp(mad_timer_count(_totalTime, MAD_UNITS_MILLISECONDS), getRate()); + // To rule out any invalid sample rate to be encountered here, say in case the + // MP3 stream is invalid, we just check the MAD error code here. + // We need to assure this, since else we might trigger an assertion in Timestamp + // (When getRate() returns 0 or a negative number to be precise). + // Note that we allow "MAD_ERROR_BUFLEN" as error code here, since according + // to mad.h it is also set on EOF. + if ((_stream.error == MAD_ERROR_NONE || _stream.error == MAD_ERROR_BUFLEN) && getRate() > 0) + _length = Timestamp(mad_timer_count(_totalTime, MAD_UNITS_MILLISECONDS), getRate()); deinitStream(); |