]> granicus.if.org Git - graphviz/commitdiff
gml2gv mkAttr: fix unchecked allocation failures
authorMatthew Fernandez <matthew.fernandez@gmail.com>
Sun, 28 Aug 2022 15:52:50 +0000 (08:52 -0700)
committerMatthew Fernandez <matthew.fernandez@gmail.com>
Tue, 30 Aug 2022 04:01:31 +0000 (21:01 -0700)
cmd/tools/gmlparse.y

index 9c438b936617f082f370fba2301ac8e47a42d560..7bde888035713d94cd14df6af22dd8d17a282098 100644 (file)
@@ -27,8 +27,6 @@
 #include <cgraph/exit.h>
 #include <cgraph/stack.h>
 
-#define NEW(t)       malloc(sizeof(t))
-
 static gmlgraph* G;
 static gmlnode* N;
 static gmledge* E;
@@ -201,11 +199,11 @@ mkEdge (void)
 
 static gmlattr *mkAttr(char* name, unsigned short sort, unsigned short kind,
                        char* str,  Dt_t* list) {
-    gmlattr* gp = NEW(gmlattr);
+    gmlattr* gp = gv_alloc(sizeof(gmlattr));
 
     assert (name || sort);
     if (!name)
-       name = strdup (sortToStr (sort));
+       name = gv_strdup (sortToStr (sort));
     gp->sort = sort;
     gp->kind = kind;
     gp->name = name;