]> granicus.if.org Git - graphviz/commitdiff
smyrna add_column: fix unchecked allocation failure
authorMatthew Fernandez <matthew.fernandez@gmail.com>
Fri, 2 Sep 2022 00:46:47 +0000 (17:46 -0700)
committerMatthew Fernandez <matthew.fernandez@gmail.com>
Fri, 2 Sep 2022 00:46:47 +0000 (17:46 -0700)
cmd/smyrna/tvnodes.c

index 5ba7a3b9bbc061d4158c6db8617395ac60a30155..ad7fbc0be298894c72ff2b0ddcd4c3f0b52adb19 100644 (file)
@@ -11,6 +11,7 @@
 #include "tvnodes.h"
 #include "viewport.h"
 #include "topviewfuncs.h"
+#include <cgraph/alloc.h>
 #include <common/memory.h>
 #include <stdbool.h>
 
@@ -309,8 +310,8 @@ static void add_column(grid * g, char *name, bool editable, GType g_type)
 {
     if (*name == '\0')
        return;
-    g->columns = realloc(g->columns,
-                            sizeof(gridCol *) * (g->count + 1));
+    g->columns = gv_recalloc(g->columns, g->count, g->count + 1,
+                             sizeof(gridCol*));
     g->columns[g->count] = NEW(gridCol);
     g->columns[g->count]->editable = editable;
     g->columns[g->count]->name = name;