From 07bccf3e362caa3b751a1623719577cbd4b44a47 Mon Sep 17 00:00:00 2001 From: Rene Kita Date: Thu, 24 Nov 2022 18:19:38 +0100 Subject: [PATCH] Exit with error if a new buffer can't be allocated When building with gcc and -Wnull-dereference, -O3 and -flto we get a lot of warnings about potential null dereferences. Exiting instead of returning NULL solves all of it. If we cannot alloc memory, there is not much to do - exiting is the easiest option. --- buffer.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/buffer.c b/buffer.c index f4a0377..7b625c1 100644 --- a/buffer.c +++ b/buffer.c @@ -28,7 +28,7 @@ newBuffer(int width) n = New(Buffer); if (n == NULL) - return NULL; + exit(3); bzero((void *)n, sizeof(Buffer)); n->width = width; n->COLS = COLS;