From: Eric Blake Date: Thu, 18 Jun 2009 21:24:38 +0000 (-0600) Subject: hash: fix memory leak in last patch X-Git-Tag: v0.1~5848 X-Git-Url: http://erislabs.org.uk/gitweb/?a=commitdiff_plain;h=eabc7530f49e976f89c8a6da1ca63e434a59daa5;p=gnulib.git hash: fix memory leak in last patch * lib/hash.c (hash_rehash): Avoid memory leak. Signed-off-by: Eric Blake --- diff --git a/ChangeLog b/ChangeLog index e7698b70c..36027fa43 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,5 +1,8 @@ 2009-06-18 Eric Blake + 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. diff --git a/lib/hash.c b/lib/hash.c index f2123b4e4..dc4a1b90e 100644 --- a/lib/hash.c +++ b/lib/hash.c @@ -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