[FFmpeg-cvslog] tools/graph2dot: Don't use sizeof(AVFilterGraph), check allocation

Andreas Rheinhardt git at videolan.org
Sat Jul 24 06:38:03 EEST 2021


ffmpeg | branch: master | Andreas Rheinhardt <andreas.rheinhardt at outlook.com> | Thu Jul 22 09:01:27 2021 +0200| [c253b180cb8fc5925d057ccd7f97399ec03cb348] | committer: Andreas Rheinhardt

tools/graph2dot: Don't use sizeof(AVFilterGraph), check allocation

Use avfilter_graph_alloc() instead of av_mallocz(sizeof(AVFilterGraph))
to allocate an AVFilterGraph; this also properly allocates the graph's
internal. The current code just happened to work because it did not
make any use of said internal.

Also check the allocation; this fixes Coverity #1292528.

Reviewed-by: Jan Ekström <jeebjp at gmail.com>
Signed-off-by: Andreas Rheinhardt <andreas.rheinhardt at outlook.com>

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

 tools/graph2dot.c | 8 +++++++-
 1 file changed, 7 insertions(+), 1 deletion(-)

diff --git a/tools/graph2dot.c b/tools/graph2dot.c
index d5c1e4e3c7..fd7ea2848e 100644
--- a/tools/graph2dot.c
+++ b/tools/graph2dot.c
@@ -113,7 +113,7 @@ int main(int argc, char **argv)
     FILE *outfile           = NULL;
     FILE *infile            = NULL;
     char *graph_string      = NULL;
-    AVFilterGraph *graph = av_mallocz(sizeof(AVFilterGraph));
+    AVFilterGraph *graph    = NULL;
     char c;
 
     av_log_set_level(AV_LOG_DEBUG);
@@ -189,6 +189,12 @@ int main(int argc, char **argv)
         *p = '\0';
     }
 
+    graph = avfilter_graph_alloc();
+    if (!graph) {
+        fprintf(stderr, "Memory allocation failure\n");
+        return 1;
+    }
+
     if (avfilter_graph_parse(graph, graph_string, NULL, NULL, NULL) < 0) {
         fprintf(stderr, "Failed to parse the graph description\n");
         return 1;



More information about the ffmpeg-cvslog mailing list