Explorar o código

fix simple_malloc malloc(0) behavior not to return non-unique pointers

Rich Felker %!s(int64=14) %!d(string=hai) anos
pai
achega
598a0147cd
Modificáronse 1 ficheiros con 1 adicións e 0 borrados
  1. 1 0
      src/malloc/__simple_malloc.c

+ 1 - 0
src/malloc/__simple_malloc.c

@@ -15,6 +15,7 @@ void *__simple_malloc(size_t n)
 	static int lock;
 	size_t align=1;
 
+	if (!n) return 0;
 	if (n > SIZE_MAX/2) goto toobig;
 
 	while (align<n && align<ALIGN)