make malloc(0) return unique pointers rather than NULL
[musl] / src / malloc / __simple_malloc.c
index c029342..c829390 100644 (file)
@@ -15,7 +15,7 @@ void *__simple_malloc(size_t n)
        static int lock;
        size_t align=1;
 
-       if (!n) return 0;
+       if (!n) n++;
        if (n > SIZE_MAX/2) goto toobig;
 
        while (align<n && align<ALIGN)