free() on a null pointer is a no-op.
authorBen Pfaff <blp@cs.stanford.edu>
Sun, 5 Sep 2004 08:14:23 +0000 (08:14 +0000)
committerBen Pfaff <blp@cs.stanford.edu>
Sun, 5 Sep 2004 08:14:23 +0000 (08:14 +0000)
src/threads/malloc.c

index 02eee99fca15b47eed79863a08f7765b5c5ce533..7af11563795e925884ecc56269bf5eb8e5950f00 100644 (file)
@@ -164,6 +164,9 @@ free (void *p)
   struct arena *a = block_to_arena (b);
   struct desc *d = a->desc;
 
+  if (p == NULL)
+    return;
+
   lock_acquire (&d->lock);
 
   /* Add block to free list. */