diff options
author | Matthew Hoops | 2015-09-15 20:44:09 -0400 |
---|---|---|
committer | Matthew Hoops | 2015-09-15 20:44:09 -0400 |
commit | 8165e9aa4c32802bba5e07570c033f966cf2dc50 (patch) | |
tree | 3963ae515808733f25f19672a979ed8522581bc1 /audio | |
parent | 6c2d828f4f9c733ae286862da73c73f3579bdccd (diff) | |
download | scummvm-rg350-8165e9aa4c32802bba5e07570c033f966cf2dc50.tar.gz scummvm-rg350-8165e9aa4c32802bba5e07570c033f966cf2dc50.tar.bz2 scummvm-rg350-8165e9aa4c32802bba5e07570c033f966cf2dc50.zip |
AUDIO: Fix uninitialized read in MP3 initialization
Thanks to chkr-private for finding the issue
Diffstat (limited to 'audio')
-rw-r--r-- | audio/decoders/mp3.cpp | 11 |
1 files changed, 5 insertions, 6 deletions
diff --git a/audio/decoders/mp3.cpp b/audio/decoders/mp3.cpp index 49d4d856ab..36233a2e13 100644 --- a/audio/decoders/mp3.cpp +++ b/audio/decoders/mp3.cpp @@ -330,8 +330,11 @@ MP3Stream::MP3Stream(Common::SeekableReadStream *inStream, DisposeAfterUse::Flag _inStream(skipID3(inStream, dispose)), _length(0, 1000) { - // Initialize the stream with some data + // Initialize the stream with some data and set the channels and rate + // variables decodeMP3Data(*_inStream); + _channels = MAD_NCHANNELS(&_frame.header); + _rate = _frame.header.samplerate; // Calculate the length of the stream while (_state != MP3_STATE_EOS) @@ -352,12 +355,8 @@ MP3Stream::MP3Stream(Common::SeekableReadStream *inStream, DisposeAfterUse::Flag _state = MP3_STATE_INIT; _inStream->seek(0); - // Decode the first chunk of data. This is necessary so that _frame - // is setup and we can retrieve channels/rate. + // Decode the first chunk of data to set up the stream again. decodeMP3Data(*_inStream); - - _channels = MAD_NCHANNELS(&_frame.header); - _rate = _frame.header.samplerate; } int MP3Stream::readBuffer(int16 *buffer, const int numSamples) { |