[FFmpeg-soc] [soc]: r2090 - in libavfilter: avfiltergraph.c avfiltergraph.h graphparser.c

vitor subversion at mplayerhq.hu
Fri Apr 4 17:35:38 CEST 2008


Author: vitor
Date: Fri Apr  4 17:35:38 2008
New Revision: 2090

Log:
Handle av_realloc() failure

Modified:
   libavfilter/avfiltergraph.c
   libavfilter/avfiltergraph.h
   libavfilter/graphparser.c

Modified: libavfilter/avfiltergraph.c
==============================================================================
--- libavfilter/avfiltergraph.c	(original)
+++ libavfilter/avfiltergraph.c	Fri Apr  4 17:35:38 2008
@@ -33,11 +33,17 @@ void avfilter_destroy_graph(AVFilterGrap
     av_freep(&graph->filters);
 }
 
-void avfilter_graph_add_filter(AVFilterGraph *graph, AVFilterContext *filter)
+int avfilter_graph_add_filter(AVFilterGraph *graph, AVFilterContext *filter)
 {
     graph->filters = av_realloc(graph->filters,
                                 sizeof(AVFilterContext*) * ++graph->filter_count);
+
+    if (!graph->filters)
+        return -1;
+
     graph->filters[graph->filter_count - 1] = filter;
+
+    return 0;
 }
 
 AVFilterContext *avfilter_graph_get_filter(AVFilterGraph *graph, char *name)
@@ -87,7 +93,9 @@ static int query_formats(AVFilterGraph *
                         return -1;
                     }
 
-                    avfilter_graph_add_filter(graph, scale);
+                    if (avfilter_graph_add_filter(graph, scale) < 0)
+                        return -1;
+
                     scale->filter->query_formats(scale);
                     if(!avfilter_merge_formats(scale-> inputs[0]->in_formats,
                                                scale-> inputs[0]->out_formats)||

Modified: libavfilter/avfiltergraph.h
==============================================================================
--- libavfilter/avfiltergraph.h	(original)
+++ libavfilter/avfiltergraph.h	Fri Apr  4 17:35:38 2008
@@ -39,7 +39,7 @@ AVFilterContext *avfilter_graph_get_filt
  * @param graph  The filter graph
  * @param filter The filter to be added
  */
-void avfilter_graph_add_filter(AVFilterGraph *graphctx, AVFilterContext *filter);
+int avfilter_graph_add_filter(AVFilterGraph *graphctx, AVFilterContext *filter);
 
 /**
  * Configure the formats of all the links in the graph.

Modified: libavfilter/graphparser.c
==============================================================================
--- libavfilter/graphparser.c	(original)
+++ libavfilter/graphparser.c	Fri Apr  4 17:35:38 2008
@@ -56,7 +56,10 @@ static int create_filter(AVFilterGraph *
                "error creating filter '%s'\n", name);
         return -1;
     }
-    avfilter_graph_add_filter(ctx, filt);
+
+    if (avfilter_graph_add_filter(ctx, filt) < 0)
+        return -1;
+
     if(avfilter_init_filter(filt, args, NULL)) {
         av_log(&log_ctx, AV_LOG_ERROR,
                "error initializing filter '%s'\n", name);



More information about the FFmpeg-soc mailing list