]> granicus.if.org Git - graphviz/commitdiff
gml2gv nameOf: fix unchecked allocation
authorMatthew Fernandez <matthew.fernandez@gmail.com>
Sun, 31 Jul 2022 16:14:14 +0000 (09:14 -0700)
committerMatthew Fernandez <matthew.fernandez@gmail.com>
Sat, 6 Aug 2022 01:01:38 +0000 (18:01 -0700)
cmd/tools/gml2gv.c

index cb94b65a0a118aaba2999d94429630e6804e058c..1da26b68bfa9d4479892b2c0186def0bba021442 100644 (file)
 #include <string.h>
 
 #include <getopt.h>
-
+#include <cgraph/alloc.h>
 #include <cgraph/exit.h>
 #include <cgraph/unreachable.h>
 
-#define N_NEW(n,t)       calloc((n),sizeof(t))
-
 static int Verbose;
 static char* gname = "";
 static FILE *outFile;
@@ -144,7 +142,7 @@ nameOf (char* name, int cnt)
        return name;
     if (cnt) {
        if (!buf)
-           buf = N_NEW (strlen(name)+32,char);  /* 32 to handle any integer plus null byte */
+           buf = gv_calloc(strlen(name) + 32, sizeof(char)); // 32 to handle any integer plus null byte
        sprintf (buf, "%s%d", name, cnt);
        return buf;
     }