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

index b20e43ea1cf6bf06f8459dde0f3c2bc23b879fec..c43b9e5a1898e9f0935c99e52a681194fdec792a 100644 (file)
@@ -8,6 +8,7 @@
  * Contributors: Details at https://graphviz.org
  *************************************************************************/
 
+#include <cgraph/alloc.h>
 #include "hotkeymap.h"
 
 static int get_mouse_mode(const char *s)
@@ -129,10 +130,10 @@ void load_mouse_actions(ViewInfo * v)
                || (strlen(line) == 0))
                continue;
 
+           v->mouse_actions = gv_recalloc(v->mouse_actions, v->mouse_action_count,
+                                          v->mouse_action_count + 1,
+                                          sizeof(mouse_action_t));
            v->mouse_action_count++;
-           v->mouse_actions =
-               realloc(v->mouse_actions,
-                       v->mouse_action_count * sizeof(mouse_action_t));
            v->mouse_actions[ind].action = get_mouse_mode(a);
            v->mouse_actions[ind].index = i;