[FFmpeg-cvslog] lavfi: handle NULL lists in avfilter_make_format_list

Mina Nagy Zaki git at videolan.org
Wed Jun 8 18:55:37 CEST 2011


ffmpeg | branch: master | Mina Nagy Zaki <mnzaki at gmail.com> | Tue Jun  7 17:42:32 2011 +0300| [47d2ca3205b53665328fe301879c339449db7a1d] | committer: Stefano Sabatini

lavfi: handle NULL lists in avfilter_make_format_list

> http://git.videolan.org/gitweb.cgi/ffmpeg.git/?a=commit;h=47d2ca3205b53665328fe301879c339449db7a1d
---

 libavfilter/avfilter.h |    5 +++--
 libavfilter/formats.c  |   13 ++++++++-----
 2 files changed, 11 insertions(+), 7 deletions(-)

diff --git a/libavfilter/avfilter.h b/libavfilter/avfilter.h
index 541dbe7..ac954ca 100644
--- a/libavfilter/avfilter.h
+++ b/libavfilter/avfilter.h
@@ -27,7 +27,7 @@
 
 #define LIBAVFILTER_VERSION_MAJOR  2
 #define LIBAVFILTER_VERSION_MINOR 14
-#define LIBAVFILTER_VERSION_MICRO  0
+#define LIBAVFILTER_VERSION_MICRO  1
 
 #define LIBAVFILTER_VERSION_INT AV_VERSION_INT(LIBAVFILTER_VERSION_MAJOR, \
                                                LIBAVFILTER_VERSION_MINOR, \
@@ -233,7 +233,8 @@ typedef struct AVFilterFormats {
  * Create a list of supported formats. This is intended for use in
  * AVFilter->query_formats().
  *
- * @param fmts list of media formats, terminated by -1
+ * @param fmts list of media formats, terminated by -1. If NULL an
+ *        empty list is created.
  * @return the format list, with no existing references
  */
 AVFilterFormats *avfilter_make_format_list(const int *fmts);
diff --git a/libavfilter/formats.c b/libavfilter/formats.c
index 101ef09..ec7fca3 100644
--- a/libavfilter/formats.c
+++ b/libavfilter/formats.c
@@ -73,15 +73,18 @@ AVFilterFormats *avfilter_merge_formats(AVFilterFormats *a, AVFilterFormats *b)
 AVFilterFormats *avfilter_make_format_list(const int *fmts)
 {
     AVFilterFormats *formats;
-    int count;
+    int count = 0;
 
-    for (count = 0; fmts[count] != -1; count++)
-        ;
+    if (fmts)
+        for (count = 0; fmts[count] != -1; count++)
+            ;
 
     formats               = av_mallocz(sizeof(AVFilterFormats));
-    formats->formats      = av_malloc(sizeof(*formats->formats) * count);
     formats->format_count = count;
-    memcpy(formats->formats, fmts, sizeof(*formats->formats) * count);
+    if (count) {
+        formats->formats  = av_malloc(sizeof(*formats->formats) * count);
+        memcpy(formats->formats, fmts, sizeof(*formats->formats) * count);
+    }
 
     return formats;
 }



More information about the ffmpeg-cvslog mailing list