From 8165e9aa4c32802bba5e07570c033f966cf2dc50 Mon Sep 17 00:00:00 2001 From: Matthew Hoops Date: Tue, 15 Sep 2015 20:44:09 -0400 Subject: AUDIO: Fix uninitialized read in MP3 initialization Thanks to chkr-private for finding the issue --- audio/decoders/mp3.cpp | 11 +++++------ 1 file changed, 5 insertions(+), 6 deletions(-) (limited to 'audio') 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) { -- cgit v1.2.3