From 33890e7b9aab0d7f77c8d00a289c2a128373f1b2 Mon Sep 17 00:00:00 2001 From: P. J. McDermott Date: Fri, 24 Feb 2023 10:07:19 -0500 Subject: demo: Prevent potential null pointer dereferences --- diff --git a/src/demo.c b/src/demo.c index 6ee46b0..4e57b45 100644 --- a/src/demo.c +++ b/src/demo.c @@ -125,7 +125,13 @@ demo(void) SDL_Palette *pal_start, *pal_end; pal = malloc(sizeof(*pal)); + if (pal == NULL) { + err(1, "Failed to allocate palette"); + } pal->colors = calloc(64, sizeof(*pal->colors)); + if (pal->colors == NULL) { + err(1, "Failed to allocate palette colors"); + } pal->ncolors = 64; i = 0; -- cgit v0.9.1