From eb0e4322e2d0d28a80e182cffad1e93cf51f130a Mon Sep 17 00:00:00 2001 From: Matthew Fernandez Date: Sat, 27 Aug 2022 15:26:58 -0700 Subject: [PATCH] gvpr mkStmts: fix unchecked allocation failure --- lib/gvpr/compile.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/lib/gvpr/compile.c b/lib/gvpr/compile.c index 46cec9594..3ce2f08b3 100644 --- a/lib/gvpr/compile.c +++ b/lib/gvpr/compile.c @@ -20,6 +20,7 @@ #include #include #include +#include #include #include #include @@ -2325,7 +2326,6 @@ static void checkGuard(Exnode_t * gp, char *src, int line) static case_stmt *mkStmts(Expr_t * prog, char *src, case_info * sp, int cnt, const char *lbl) { - case_stmt *cs; int i; static const char LONGEST_CALLER_PREFIX[] = "_begin_g_"; static const char LONGEST_INFIX[] = "__a"; @@ -2336,7 +2336,7 @@ static case_stmt *mkStmts(Expr_t * prog, char *src, case_info * sp, assert(strlen(lbl) + sizeof(LONGEST_INFIX) - 1 + CHARS_FOR_NUL_TERM_INT - 1 + 1 <= sizeof(tmp)); - cs = newof(0, case_stmt, cnt, 0); + case_stmt *cs = gv_calloc(cnt, sizeof(case_stmt)); for (i = 0; i < cnt; i++) { if (sp->guard) { -- 2.40.0