summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorP. J. McDermott <pj@pehjota.net>2023-02-24 10:07:19 (EST)
committer P. J. McDermott <pj@pehjota.net>2023-02-24 10:07:19 (EST)
commit33890e7b9aab0d7f77c8d00a289c2a128373f1b2 (patch)
tree9b669536558ac93418ce282af22af1d3f440433d
parent0b360f0c7de63ddb9bb20d2fead9e077d9fef735 (diff)
downloadoverworld-rpg-33890e7b9aab0d7f77c8d00a289c2a128373f1b2.zip
overworld-rpg-33890e7b9aab0d7f77c8d00a289c2a128373f1b2.tar.gz
overworld-rpg-33890e7b9aab0d7f77c8d00a289c2a128373f1b2.tar.bz2
demo: Prevent potential null pointer dereferences
-rw-r--r--src/demo.c6
1 files changed, 6 insertions, 0 deletions
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;