]> granicus.if.org Git - graphviz/commitdiff
tred: replace a 'malloc' with cgraph alloc wrapper
authorMatthew Fernandez <matthew.fernandez@gmail.com>
Tue, 17 May 2022 14:25:44 +0000 (07:25 -0700)
committerMatthew Fernandez <matthew.fernandez@gmail.com>
Thu, 26 May 2022 04:02:55 +0000 (21:02 -0700)
This addresses a case where allocation failure went unchecked.

cmd/tools/tred.c

index 2078433950aab6d59368a49e55a28f7227744a56..a860f2ee1bb47d1a4a0e446ee8421828230a4b44 100644 (file)
@@ -22,6 +22,7 @@
  * transitive reduction on stdout
  */
 
+#include <cgraph/alloc.h>
 #include <cgraph/cgraph.h>
 #include <cgraph/stack.h>
 #include <cgraph/exit.h>
@@ -232,7 +233,7 @@ static void process(Agraph_t *g, gv_stack_t *sp) {
     size_t infosize;
 
     infosize = (agnnodes(g)+1)*sizeof(nodeinfo_t);
-    ninfo = malloc(infosize);
+    ninfo = gv_alloc(infosize);
 
     if (Verbose)
        fprintf(stderr, "Processing graph %s\n", agnameof(g));