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.
This commit is contained in:
Rene Kita
2022-11-24 18:19:38 +01:00
committed by Tatsuya Kinoshita
parent 3750197410
commit 07bccf3e36

View File

@@ -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;