diff --git a/libavformat/utils.c b/libavformat/utils.c index 3fce3fa87b..0c1a50d816 100644 --- a/libavformat/utils.c +++ b/libavformat/utils.c @@ -499,7 +499,9 @@ int av_open_input_file(AVFormatContext **ic_ptr, const char *filename, av_freep(&pd->buf); if (pb) url_fclose(pb); - av_freep(ic_ptr); + if (ap && ap->prealloced_context) + av_free(*ic_ptr); + *ic_ptr = NULL; return err; }