From efa4d09c48c061a051206a7d396cbe29b63d3913 Mon Sep 17 00:00:00 2001 From: scrawl Date: Sat, 1 Nov 2014 19:32:07 +0100 Subject: [PATCH] Fix crash when avcodec_decode_audio4 doesn't return a full frame (Fixes #2088) --- apps/openmw/mwsound/ffmpeg_decoder.cpp | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-) diff --git a/apps/openmw/mwsound/ffmpeg_decoder.cpp b/apps/openmw/mwsound/ffmpeg_decoder.cpp index 2002bded7..f724d523c 100644 --- a/apps/openmw/mwsound/ffmpeg_decoder.cpp +++ b/apps/openmw/mwsound/ffmpeg_decoder.cpp @@ -107,6 +107,9 @@ bool FFmpeg_Decoder::getAVAudioData() av_shrink_packet(&mPacket, remaining); } + if (!got_frame || mFrame->nb_samples == 0) + continue; + if(mSwr) { if(!mDataBuf || mDataBufLen < mFrame->nb_samples) @@ -114,7 +117,7 @@ bool FFmpeg_Decoder::getAVAudioData() av_freep(&mDataBuf); if(av_samples_alloc(&mDataBuf, NULL, av_get_channel_layout_nb_channels(mOutputChannelLayout), mFrame->nb_samples, mOutputSampleFormat, 0) < 0) - break; + return false; else mDataBufLen = mFrame->nb_samples; } @@ -122,7 +125,7 @@ bool FFmpeg_Decoder::getAVAudioData() if(swr_convert(mSwr, (uint8_t**)&mDataBuf, mFrame->nb_samples, (const uint8_t**)mFrame->extended_data, mFrame->nb_samples) < 0) { - break; + return false; } mFrameData = &mDataBuf; }