From 590e1196d098c826cd566f9f01f09b55a5115487 Mon Sep 17 00:00:00 2001 From: Anonymous Maarten Date: Thu, 24 Oct 2024 23:53:44 +0200 Subject: [PATCH] snake: check allocated memory before use --- examples/game/01-snake/snake.c | 3 +++ 1 file changed, 3 insertions(+) diff --git a/examples/game/01-snake/snake.c b/examples/game/01-snake/snake.c index 95aeeffca6..6df07a1f51 100644 --- a/examples/game/01-snake/snake.c +++ b/examples/game/01-snake/snake.c @@ -310,6 +310,9 @@ SDL_AppResult SDL_AppInit(void **appstate, int argc, char *argv[]) } AppState *as = SDL_calloc(1, sizeof(AppState)); + if (!as) { + return SDL_APP_FAILURE; + } *appstate = as;