Ernst Albrecht Köstlin <m...@alks.org> added the comment: Doing so won't free the already allocated structures AVFormatContext's "stream" array entries are pointing to, neither would it set AVFormatContext's nb_stream to 0.
So Id propose the following: --- libavformat/ffmdec.c 2010-07-20 21:19:05.000000000 +0200 +++ libavformat/ffmdec_patched.c 2010-07-20 21:18:48.000000000 +0200 @@ -251,6 +251,7 @@ url_fseek(pb, ptr, SEEK_SET); } +static int ffm_close(AVFormatContext *); static int ffm_read_header(AVFormatContext *s, AVFormatParameters *ap) { @@ -381,12 +382,11 @@ ffm->first_packet = 1; return 0; fail: + ffm_close(s); for(i=0;i<s->nb_streams;i++) { - st = s->streams[i]; - if (st) { - av_free(st); - } + av_freep(&s->streams[i]); } + s->nb_streams = 0; return -1; } ________________________________________________ FFmpeg issue tracker <iss...@roundup.ffmpeg.org> <https://roundup.ffmpeg.org/issue2003> ________________________________________________