hash: fix memory leak in last patch
authorEric Blake <ebb9@byu.net>
Thu, 18 Jun 2009 21:24:38 +0000 (15:24 -0600)
committerEric Blake <ebb9@byu.net>
Fri, 19 Jun 2009 01:54:35 +0000 (19:54 -0600)
* lib/hash.c (hash_rehash): Avoid memory leak.

Signed-off-by: Eric Blake <ebb9@byu.net>
ChangeLog
lib/hash.c

index e7698b70c254c5a556ae0e8d5af783e73939a8b0..36027fa4355361c9eb8b89b397d8889df9db89e6 100644 (file)
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,5 +1,8 @@
 2009-06-18  Eric Blake  <ebb9@byu.net>
 
+       hash: fix memory leak in last patch
+       * lib/hash.c (hash_rehash): Avoid memory leak.
+
        hash: avoid no-op rehashing
        * lib/hash.c (hash_rehash): Recognize useless rehash attempts.
 
index f2123b4e4cd78d571fed82edae27953d1cf3189b..dc4a1b90e83953bf2097ca60389da949fad6778d 100644 (file)
@@ -863,7 +863,11 @@ hash_rehash (Hash_table *table, size_t candidate)
   if (new_table == NULL)
     return false;
   if (new_table->n_buckets == table->n_buckets)
-    return true;
+    {
+      free (new_table->bucket);
+      free (new_table);
+      return true;
+    }
 
   /* Merely reuse the extra old space into the new table.  */
 #if USE_OBSTACK