From eabc7530f49e976f89c8a6da1ca63e434a59daa5 Mon Sep 17 00:00:00 2001 From: Eric Blake Date: Thu, 18 Jun 2009 15:24:38 -0600 Subject: [PATCH] hash: fix memory leak in last patch * lib/hash.c (hash_rehash): Avoid memory leak. Signed-off-by: Eric Blake --- ChangeLog | 3 +++ lib/hash.c | 6 +++++- 2 files changed, 8 insertions(+), 1 deletion(-) diff --git a/ChangeLog b/ChangeLog index e7698b70c2..36027fa435 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 f2123b4e4c..dc4a1b90e8 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 -- 2.30.2