From bfd3b70ac3162f028bbfa5a8cd47d2715d49f77e Mon Sep 17 00:00:00 2001
From: Michael Niedermayer <michaelni@gmx.at>
Date: Sat, 4 Jun 2011 01:24:00 +0200
Subject: [PATCH] ffmpeg: fix segfault with too many output files

Fixes Ticket219

Signed-off-by: Michael Niedermayer <michaelni@gmx.at>
---
 ffmpeg.c | 5 +++++
 1 file changed, 5 insertions(+)

diff --git a/ffmpeg.c b/ffmpeg.c
index e5986a6a38..35436aa1f2 100644
--- a/ffmpeg.c
+++ b/ffmpeg.c
@@ -3863,6 +3863,11 @@ static void opt_output_file(const char *filename)
     AVFormatParameters params, *ap = &params;
     AVOutputFormat *file_oformat;
 
+    if(nb_output_files >= FF_ARRAY_ELEMS(output_files)){
+        fprintf(stderr, "Too many output files\n");
+        ffmpeg_exit(1);
+    }
+
     if (!strcmp(filename, "-"))
         filename = "pipe:";