hash: fix memory leak in last patch
* lib/hash.c (hash_rehash): Avoid memory leak.
Signed-off-by: Eric Blake <ebb9@byu.net>
author |
Eric Blake <ebb9@byu.net> |
date |
Thu, 18 Jun 2009 15:24:38 -0600 |
parents |
bddc78d1a1c2 |
children |
66e1eeffb344 |
files |
ChangeLog lib/hash.c |
diffstat |
2 files changed, 8 insertions(+), 1 deletions(-)
[+]
|
line diff
--- 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.
--- a/lib/hash.c
+++ b/lib/hash.c
@@ -863,7 +863,11 @@
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