ffmpeg: Fix cleanup after failed allocation of output_files
authorMichael Niedermayer <michael@niedermayer.cc>
Tue, 14 Jul 2015 13:49:41 +0000 (15:49 +0200)
committerMichael Niedermayer <michael@niedermayer.cc>
Tue, 14 Jul 2015 13:59:11 +0000 (15:59 +0200)
Fixes: 39a25908b84604acdaa490138282d091_signal_sigsegv_7ffff713351a_331_WAWV.avi with memlimit of 262144

Found-by: Samuel GroƟ, Mateusz "j00ru" Jurczyk and Gynvael Coldwind
Signed-off-by: Michael Niedermayer <michael@niedermayer.cc>
ffmpeg.c

index cb50187..844034e 100644 (file)
--- a/ffmpeg.c
+++ b/ffmpeg.c
@@ -500,7 +500,10 @@ static void ffmpeg_cleanup(int ret)
     /* close files */
     for (i = 0; i < nb_output_files; i++) {
         OutputFile *of = output_files[i];
-        AVFormatContext *s = of->ctx;
+        AVFormatContext *s;
+        if (!of)
+            continue;
+        s = of->ctx;
         if (s && s->oformat && !(s->oformat->flags & AVFMT_NOFILE))
             avio_closep(&s->pb);
         avformat_free_context(s);