[FFmpeg-cvslog] r22905 - trunk/libavfilter/avfiltergraph.c

stefano subversion
Sun Apr 18 22:10:44 CEST 2010


Author: stefano
Date: Sun Apr 18 22:10:43 2010
New Revision: 22905

Log:
Fix leak in avfilter_graph_add_filter().

In case of reallocation failure the pointer to the original filter
array was lost. The correct behavior seems to just keep the old array
and count.

Modified:
   trunk/libavfilter/avfiltergraph.c

Modified: trunk/libavfilter/avfiltergraph.c
==============================================================================
--- trunk/libavfilter/avfiltergraph.c	Sun Apr 18 21:09:25 2010	(r22904)
+++ trunk/libavfilter/avfiltergraph.c	Sun Apr 18 22:10:43 2010	(r22905)
@@ -36,13 +36,13 @@ void avfilter_graph_destroy(AVFilterGrap
 
 int avfilter_graph_add_filter(AVFilterGraph *graph, AVFilterContext *filter)
 {
-    graph->filters = av_realloc(graph->filters,
-                                sizeof(AVFilterContext*) * ++graph->filter_count);
-
-    if (!graph->filters)
+    AVFilterContext **filters = av_realloc(graph->filters,
+                                           sizeof(AVFilterContext*) * (graph->filter_count+1));
+    if (!filters)
         return AVERROR(ENOMEM);
 
-    graph->filters[graph->filter_count - 1] = filter;
+    graph->filters = filters;
+    graph->filters[graph->filter_count++] = filter;
 
     return 0;
 }



More information about the ffmpeg-cvslog mailing list