1
0
mirror of https://gitlab.com/OpenMW/openmw.git synced 2025-03-10 16:14:26 +00:00

Fix crash when avformat_open_input fails (Fixes #1522)

This commit is contained in:
scrawl 2014-06-17 21:16:32 +02:00
parent d4678a8d55
commit 80f66e2157

View File

@ -158,6 +158,9 @@ void FFmpeg_Decoder::open(const std::string &fname)
mFormatCtx->pb = avio_alloc_context(NULL, 0, 0, this, readPacket, writePacket, seek); mFormatCtx->pb = avio_alloc_context(NULL, 0, 0, this, readPacket, writePacket, seek);
if(!mFormatCtx->pb || avformat_open_input(&mFormatCtx, fname.c_str(), NULL, NULL) != 0) if(!mFormatCtx->pb || avformat_open_input(&mFormatCtx, fname.c_str(), NULL, NULL) != 0)
{
// "Note that a user-supplied AVFormatContext will be freed on failure".
if (mFormatCtx)
{ {
if (mFormatCtx->pb != NULL) if (mFormatCtx->pb != NULL)
{ {
@ -170,6 +173,7 @@ void FFmpeg_Decoder::open(const std::string &fname)
mFormatCtx->pb = NULL; mFormatCtx->pb = NULL;
} }
avformat_free_context(mFormatCtx); avformat_free_context(mFormatCtx);
}
mFormatCtx = NULL; mFormatCtx = NULL;
fail("Failed to allocate input stream"); fail("Failed to allocate input stream");
} }