avfilter: dont write out of array for duplicate formats in avfilter_merge_formats()
authorMichael Niedermayer <michaelni@gmx.at>
Wed, 23 Nov 2011 12:18:11 +0000 (13:18 +0100)
committerMichael Niedermayer <michaelni@gmx.at>
Wed, 23 Nov 2011 12:18:11 +0000 (13:18 +0100)
Note, this is a theoretical fix, iam not aware of a case where this function receives
duplicates in its input.

Signed-off-by: Michael Niedermayer <michaelni@gmx.at>
libavfilter/formats.c

index b77ca8a..c626b38 100644 (file)
@@ -56,8 +56,10 @@ AVFilterFormats *avfilter_merge_formats(AVFilterFormats *a, AVFilterFormats *b)
                                                            b->format_count));
     for (i = 0; i < a->format_count; i++)
         for (j = 0; j < b->format_count; j++)
-            if (a->formats[i] == b->formats[j])
+            if (a->formats[i] == b->formats[j]){
                 ret->formats[k++] = a->formats[i];
+                break;
+            }
 
     ret->format_count = k;
     /* check that there was at least one common format */