Commit c253b180 authored by Andreas Rheinhardt's avatar 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: 's avatarJan Ekström <jeebjp@gmail.com>
Signed-off-by: 's avatarAndreas Rheinhardt <andreas.rheinhardt@outlook.com>
parent 4ff73add
......@@ -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;
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment