From a05369f0f6646a30db0641294264b2862a56fcf8 Mon Sep 17 00:00:00 2001 From: stderr64 Date: Wed, 27 Nov 2024 22:06:18 +0200 Subject: [PATCH] Initialize allocated memory and check that node is not NULL before using it --- objects/screen.c | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/objects/screen.c b/objects/screen.c index d3772efdd..42e17d377 100644 --- a/objects/screen.c +++ b/objects/screen.c @@ -500,7 +500,8 @@ viewport_add(lua_State *L, int x, int y, int w, int h) } } while (a && (a = a->next)); - viewport_t *node = malloc(sizeof(viewport_t)); + viewport_t *node = calloc(1, sizeof(viewport_t)); + assert( node != NULL ); node->x = x; node->y = y; node->width = w;