Explorar o código

check for a 0 size first, then check for a NULL pointer

Mike Frysinger %!s(int64=20) %!d(string=hai) anos
pai
achega
31ff6e059f
Modificáronse 1 ficheiros con 2 adicións e 2 borrados
  1. 2 2
      libc/stdlib/malloc/realloc.c

+ 2 - 2
libc/stdlib/malloc/realloc.c

@@ -28,13 +28,13 @@ realloc (void *mem, size_t new_size)
   char *base_mem;
 
   /* Check for special cases.  */
-  if (! mem)
-    return malloc (new_size);
   if (! new_size)
     {
       free (mem);
       return malloc (new_size);
     }
+  if (! mem)
+    return malloc (new_size);
 
   /* Normal realloc.  */