Initialize allocated memory and check that node is not NULL before using it

This commit is contained in:
stderr64 2024-11-27 22:06:18 +02:00
parent 0f950cbb62
commit a05369f0f6
1 changed files with 2 additions and 1 deletions

View File

@ -500,7 +500,8 @@ viewport_add(lua_State *L, int x, int y, int w, int h)
} }
} while (a && (a = a->next)); } 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->x = x;
node->y = y; node->y = y;
node->width = w; node->width = w;