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);
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)
{
@ -170,6 +173,7 @@ void FFmpeg_Decoder::open(const std::string &fname)
mFormatCtx->pb = NULL;
}
avformat_free_context(mFormatCtx);
}
mFormatCtx = NULL;
fail("Failed to allocate input stream");
}