[FFmpeg-cvslog] r16565 - trunk/libavfilter/avfilter.c

stefano subversion
Mon Jan 12 21:30:58 CET 2009


Author: stefano
Date: Mon Jan 12 21:30:57 2009
New Revision: 16565

Log:
Make avfilter_open() set to NULL the pads and the filters when the
corresponding count is zero, rather than allocate a 16 bytes sized
block for them. Improve safety.

Modified:
   trunk/libavfilter/avfilter.c

Modified: trunk/libavfilter/avfilter.c
==============================================================================
--- trunk/libavfilter/avfilter.c	Mon Jan 12 01:07:40 2009	(r16564)
+++ trunk/libavfilter/avfilter.c	Mon Jan 12 21:30:57 2009	(r16565)
@@ -341,7 +341,7 @@ AVFilterContext *avfilter_open(AVFilter 
     if (!filter)
         return 0;
 
-    ret = av_malloc(sizeof(AVFilterContext));
+    ret = av_mallocz(sizeof(AVFilterContext));
 
     ret->av_class = &avfilter_class;
     ret->filter   = filter;
@@ -349,14 +349,18 @@ AVFilterContext *avfilter_open(AVFilter 
     ret->priv     = av_mallocz(filter->priv_size);
 
     ret->input_count  = pad_count(filter->inputs);
+    if (ret->input_count) {
     ret->input_pads   = av_malloc(sizeof(AVFilterPad) * ret->input_count);
     memcpy(ret->input_pads, filter->inputs, sizeof(AVFilterPad)*ret->input_count);
     ret->inputs       = av_mallocz(sizeof(AVFilterLink*) * ret->input_count);
+    }
 
     ret->output_count = pad_count(filter->outputs);
+    if (ret->output_count) {
     ret->output_pads  = av_malloc(sizeof(AVFilterPad) * ret->output_count);
     memcpy(ret->output_pads, filter->outputs, sizeof(AVFilterPad)*ret->output_count);
     ret->outputs      = av_mallocz(sizeof(AVFilterLink*) * ret->output_count);
+    }
 
     return ret;
 }




More information about the ffmpeg-cvslog mailing list