]> granicus.if.org Git - graphviz/commitdiff
smyrna add_graph_to_viewport: fix unchecked allocation failure
authorMatthew Fernandez <matthew.fernandez@gmail.com>
Fri, 2 Sep 2022 01:14:05 +0000 (18:14 -0700)
committerMatthew Fernandez <matthew.fernandez@gmail.com>
Fri, 2 Sep 2022 01:14:05 +0000 (18:14 -0700)
cmd/smyrna/viewport.c

index 3bf1229556784c572fef29a269e3376503c69005..7aed95dd407de44b5d75308edbeb84482355aaa1 100644 (file)
@@ -13,6 +13,7 @@
 #endif
 #include "viewport.h"
 #include "draw.h"
+#include <cgraph/alloc.h>
 #include <common/color.h>
 #include <glade/glade.h>
 #include "gui.h"
@@ -517,9 +518,9 @@ static void activate(int id)
 int add_graph_to_viewport(Agraph_t * graph, char *id)
 {
     if (graph) {
+       view->g = gv_recalloc(view->g, view->graphCount, view->graphCount + 1,
+                             sizeof(Agraph_t*));
        view->graphCount = view->graphCount + 1;
-       view->g = realloc(view->g,
-                                 sizeof(Agraph_t *) * view->graphCount);
        view->g[view->graphCount - 1] = graph;
 
        gtk_combo_box_append_text(view->graphComboBox, id);