From 49ec4c7e49a4fe309d85a2e85a21ee526fc162c8 Mon Sep 17 00:00:00 2001
From: Michael Niedermayer <michaelni@gmx.at>
Date: Thu, 2 May 2013 16:01:28 +0200
Subject: [PATCH] ffmpeg: fix segfault with random output

Found-by: <durandal_1707>
Signed-off-by: Michael Niedermayer <michaelni@gmx.at>
---
 ffmpeg.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/ffmpeg.c b/ffmpeg.c
index 86f5da3900a..776312a96d6 100644
--- a/ffmpeg.c
+++ b/ffmpeg.c
@@ -452,7 +452,7 @@ static void exit_program(void)
     /* close files */
     for (i = 0; i < nb_output_files; i++) {
         AVFormatContext *s = output_files[i]->ctx;
-        if (!(s->oformat->flags & AVFMT_NOFILE) && s->pb)
+        if (s && !(s->oformat->flags & AVFMT_NOFILE) && s->pb)
             avio_close(s->pb);
         avformat_free_context(s);
         av_dict_free(&output_files[i]->opts);
-- 
GitLab