From 2854f6ca839d4d77b9bb335762911bd692c4974d Mon Sep 17 00:00:00 2001 From: Andrei Kortunov Date: Thu, 14 Jun 2018 21:32:40 +0400 Subject: [PATCH] Handle exception if we try to play non-music file (bug #4416) --- CHANGELOG.md | 1 + apps/openmw/mwsound/ffmpeg_decoder.cpp | 21 ++++++++++++--------- 2 files changed, 13 insertions(+), 9 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index 3a59aca8e..22b589ed1 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -22,6 +22,7 @@ Bug #4327: Missing animations during spell/weapon stance switching Bug #4368: Settings window ok button doesn't have key focus by default Bug #4393: NPCs walk back to where they were after using ResetActors + Bug #4416: Handle exception if we try to play non-music file Bug #4419: MRK NiStringExtraData is handled incorrectly Bug #4426: RotateWorld behavior is incorrect Bug #4429: [Windows] Error on build INSTALL.vcxproj project (debug) with cmake 3.7.2 diff --git a/apps/openmw/mwsound/ffmpeg_decoder.cpp b/apps/openmw/mwsound/ffmpeg_decoder.cpp index e2d54876f..f458c0a97 100644 --- a/apps/openmw/mwsound/ffmpeg_decoder.cpp +++ b/apps/openmw/mwsound/ffmpeg_decoder.cpp @@ -251,21 +251,24 @@ void FFmpeg_Decoder::open(const std::string &fname) if(mOutputChannelLayout == 0) mOutputChannelLayout = av_get_default_channel_layout((*mStream)->codec->channels); } - catch(...) { + catch(...) + { if(mStream) avcodec_close((*mStream)->codec); mStream = NULL; - if (mFormatCtx->pb->buffer != NULL) + if (mFormatCtx != NULL) { - av_free(mFormatCtx->pb->buffer); - mFormatCtx->pb->buffer = NULL; - } - av_free(mFormatCtx->pb); - mFormatCtx->pb = NULL; + if (mFormatCtx->pb->buffer != NULL) + { + av_free(mFormatCtx->pb->buffer); + mFormatCtx->pb->buffer = NULL; + } + av_free(mFormatCtx->pb); + mFormatCtx->pb = NULL; - avformat_close_input(&mFormatCtx); - throw; + avformat_close_input(&mFormatCtx); + } } }