]> granicus.if.org Git - graphviz/commitdiff
dijkstra init: fix unchecked allocation failure
authorMatthew Fernandez <matthew.fernandez@gmail.com>
Sun, 28 Aug 2022 16:08:00 +0000 (09:08 -0700)
committerMatthew Fernandez <matthew.fernandez@gmail.com>
Tue, 30 Aug 2022 04:01:31 +0000 (21:01 -0700)
cmd/tools/dijkstra.c

index 7fddaed1cf16217d4f56af6263add4ee12f7ffce..ed6cbefe4b3c28587adafd59cedf6d4dd9275505 100644 (file)
@@ -19,6 +19,7 @@
 #include <stdio.h>
 #include <stdlib.h>
 #include <math.h>
+#include <cgraph/alloc.h>
 #include <cgraph/cgraph.h>
 #include <cgraph/exit.h>
 #include <ingraphs/ingraphs.h>
@@ -269,8 +270,8 @@ static void init(int argc, char *argv[])
        fprintf(stderr, "%s: no node specified\n", CmdName);
        usage(1);
     }
-    Files = calloc(sizeof(char *), (size_t)argc / 2 + 2);
-    Nodes = calloc(sizeof(char *), (size_t)argc / 2 + 2);
+    Files = gv_calloc((size_t)argc / 2 + 2, sizeof(char *));
+    Nodes = gv_calloc((size_t)argc / 2 + 2, sizeof(char *));
     for (j = i = 0; i < argc; i++) {
        Nodes[j] = argv[i++];
        Files[j] = argv[i] ? argv[i] : "-";