]> xenbits.xensource.com Git - freebsd.git/commitdiff
loader: Malloc(0) should return NULL.
authortsoome <tsoome@FreeBSD.org>
Mon, 16 Sep 2019 20:28:08 +0000 (20:28 +0000)
committertsoome <tsoome@FreeBSD.org>
Mon, 16 Sep 2019 20:28:08 +0000 (20:28 +0000)
We really should not allocate anything with size 0.

stand/libsa/zalloc_malloc.c

index b9a295fb3850338e7b23dcaad74becfab632e8b9..2cc14d80641d5e71b718137a2e1d739e4027403b 100644 (file)
@@ -55,6 +55,9 @@ Malloc(size_t bytes, const char *file, int line)
 {
     Guard *res;
 
+    if (bytes == 0)
+       return (NULL);
+
 #ifdef USEENDGUARD
     bytes += MALLOCALIGN + 1;
 #else