]> granicus.if.org Git - graphviz/commitdiff
gvpr addCase: fix unchecked allocation failure
authorMatthew Fernandez <matthew.fernandez@gmail.com>
Sat, 27 Aug 2022 22:31:59 +0000 (15:31 -0700)
committerMatthew Fernandez <matthew.fernandez@gmail.com>
Tue, 30 Aug 2022 03:01:58 +0000 (20:01 -0700)
lib/gvpr/parse.c

index 66e2e062beb64e23e15d1e5ff0f759ab5a38f0ae..37db5199642a0472ecf3cfff590a0e439859ea29 100644 (file)
@@ -411,8 +411,6 @@ static parse_block *addBlock (parse_block * last, char *stmt, int line,
 static case_info *addCase(case_info * last, char *guard, int gline,
                          char *action, int line, int *cnt)
 {
-    case_info *item;
-
     if (!guard && !action) {
        error(ERROR_WARNING,
              "Case with neither guard nor action, line %d - ignored", kwLine);
@@ -420,7 +418,7 @@ static case_info *addCase(case_info * last, char *guard, int gline,
     }
 
     ++(*cnt);
-    item = newof(0, case_info, 1, 0);
+    case_info *item = gv_alloc(sizeof(case_info));
     item->guard = guard;
     item->action = action;
     item->next = NULL;