forked from mirror/openmw-tes3mp
Fix crash when avformat_open_input fails (Fixes #1522)
This commit is contained in:
parent
d4678a8d55
commit
80f66e2157
1 changed files with 13 additions and 9 deletions
|
@ -159,17 +159,21 @@ 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)
|
||||
{
|
||||
if (mFormatCtx->pb != NULL)
|
||||
// "Note that a user-supplied AVFormatContext will be freed on failure".
|
||||
if (mFormatCtx)
|
||||
{
|
||||
if (mFormatCtx->pb->buffer != NULL)
|
||||
{
|
||||
av_free(mFormatCtx->pb->buffer);
|
||||
mFormatCtx->pb->buffer = NULL;
|
||||
}
|
||||
av_free(mFormatCtx->pb);
|
||||
mFormatCtx->pb = NULL;
|
||||
if (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_free_context(mFormatCtx);
|
||||
}
|
||||
avformat_free_context(mFormatCtx);
|
||||
mFormatCtx = NULL;
|
||||
fail("Failed to allocate input stream");
|
||||
}
|
||||
|
|
Loading…
Reference in a new issue