Browse Source

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

Mike Frysinger 18 years ago
parent
commit
31ff6e059f
1 changed files with 2 additions and 2 deletions
  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.  */