diff options
author | Colin Snover | 2017-11-19 20:44:40 -0600 |
---|---|---|
committer | Colin Snover | 2017-11-19 20:53:02 -0600 |
commit | e42ade073cc1f013eae739dc37464630f1104813 (patch) | |
tree | 77a4b6a8831a9e016b79abce506dff9ad71efe20 | |
parent | 9fc24e19f234ba53fb450223137a8041932ecd51 (diff) | |
download | scummvm-rg350-e42ade073cc1f013eae739dc37464630f1104813.tar.gz scummvm-rg350-e42ade073cc1f013eae739dc37464630f1104813.tar.bz2 scummvm-rg350-e42ade073cc1f013eae739dc37464630f1104813.zip |
AUDIO: Fix uninitialized data structures in PacketizedMP3Stream
If the audio thread called to readBuffer before any packet had been
added to the stream, the state of the stream would be changed from
INIT to EOS. Later, when a packet was received, the state would go
directly from EOS to READY, skipping decoder init, leaving garbage
memory in the decoder structs and causing a crash of the decoder.
Fixes Trac#9653.
-rw-r--r-- | audio/decoders/mp3.cpp | 5 |
1 files changed, 4 insertions, 1 deletions
diff --git a/audio/decoders/mp3.cpp b/audio/decoders/mp3.cpp index 54da6c584d..3fd134df41 100644 --- a/audio/decoders/mp3.cpp +++ b/audio/decoders/mp3.cpp @@ -453,7 +453,10 @@ int PacketizedMP3Stream::readBuffer(int16 *buffer, const int numSamples) { while (samples < numSamples) { // Empty? Bail out for now, and mark the stream as ended if (_queue.empty()) { - _state = MP3_STATE_EOS; + // EOS state is only valid once a packet has been received at least + // once + if (_state == MP3_STATE_READY) + _state = MP3_STATE_EOS; return samples; } |