]> granicus.if.org Git - graphviz/commitdiff
core plugin: fix unchecked allocation failure in dot rendering
authorMatthew Fernandez <matthew.fernandez@gmail.com>
Sat, 2 Jul 2022 15:45:18 +0000 (08:45 -0700)
committerMatthew Fernandez <matthew.fernandez@gmail.com>
Mon, 4 Jul 2022 23:55:51 +0000 (16:55 -0700)
plugin/core/gvrender_core_dot.c

index 93e038a87a65b55d648896c2360dd4f7292ed2c9..1991bfa25fef1226e08326e0abdf4d9d9fe278bb 100644 (file)
@@ -25,6 +25,7 @@
 
 #include <gvc/gvplugin_render.h>
 #include <gvc/gvplugin_device.h>
+#include <cgraph/alloc.h>
 #include <cgraph/agxbuf.h>
 #include <cgraph/prisize_t.h>
 #include <cgraph/unreachable.h>
@@ -32,8 +33,6 @@
 #include <gvc/gvc.h>
 #include <gvc/gvio.h>
 
-#define GNEW(t)          malloc(sizeof(t))
-
 /* #define NEW_XDOT */
 
 typedef enum {
@@ -415,7 +414,7 @@ xdot_begin_graph (graph_t *g, int s_arrows, int e_arrows, format_type id)
     unsigned short us;
     char* s;
 
-    xd = GNEW(xdot_state_t);
+    xd = gv_alloc(sizeof(xdot_state_t));
 
     if (id == FORMAT_XDOT14) {
        xd->version = 14;