From 67af2eead2b9424ba311ef208cd45df839c3efbe Mon Sep 17 00:00:00 2001 From: Kimplul Date: Sat, 11 Jan 2025 16:35:19 +0200 Subject: fix some analyzer warnings --- src/ast.c | 12 ++++++++++++ 1 file changed, 12 insertions(+) (limited to 'src/ast.c') diff --git a/src/ast.c b/src/ast.c index 5cfafdd..daf393e 100644 --- a/src/ast.c +++ b/src/ast.c @@ -76,6 +76,9 @@ static struct ast *create_empty_ast() } struct ast *n = calloc(1, sizeof(struct ast)); + if (!n) + return NULL; + /* just to be safe */ n->k = AST_EMPTY; vect_append(struct ast *, nodes, &n); @@ -89,6 +92,9 @@ static struct type *create_empty_type() } struct type *n = calloc(1, sizeof(struct type)); + if (!n) + return NULL; + /* just to be safe */ n->k = TYPE_VOID; n->size = -1; @@ -393,6 +399,9 @@ struct ast *clone_ast(struct ast *n) assert(n->k); struct ast *new = create_empty_ast(); + if (!new) + return NULL; + new->scope = n->scope; new->loc = n->loc; new->k = n->k; @@ -435,6 +444,9 @@ struct type *clone_type(struct type *n) assert(n->k); struct type *new = create_empty_type(); + if (!new) + return NULL; + new->scope = n->scope; new->loc = n->loc; new->k = n->k; -- cgit v1.3