[FFmpeg-devel] [PATCH] Fix avfilter crash in ff_merge_formats

Brian C. Wiles brian at poldon.com
Sun Apr 6 06:23:00 CEST 2014


Hi,

   I ran across a crash when setting up filter graphs and thought I'd 
help fix it.  Here's a patch to fix the crash, which is just a missing 
NULL pointer check.  Please let me know if you have any questions.

   Thanks.

-Brian

--- a/libavfilter/formats.c    2014-04-05 23:05:43.604035708 -0500
+++ b/libavfilter/formats.c    2014-04-05 23:06:07.784119097 -0500
@@ -112,6 +112,12 @@
              for (j = 0; j < b->nb_formats; j++) {
                  const AVPixFmtDescriptor *adesc = 
av_pix_fmt_desc_get(a->formats[i]);
                  const AVPixFmtDescriptor *bdesc = 
av_pix_fmt_desc_get(b->formats[j]);
+
+                if(!adesc || !bdesc)    // If either format is NULL, we 
can't merge.
+                {
+                    return NULL;
+                }
+
                  alpha2 |= adesc->flags & bdesc->flags & 
AV_PIX_FMT_FLAG_ALPHA;
                  chroma2|= adesc->nb_components > 1 && 
bdesc->nb_components > 1;
                  if (a->formats[i] == b->formats[j]) {



More information about the ffmpeg-devel mailing list