]> git.ipfire.org Git - thirdparty/libnl.git/commitdiff
hashtable: Fix reference leak in nl_hashtable_free()
authorThomas Graf <tgraf@suug.ch>
Sat, 10 Nov 2012 09:52:26 +0000 (10:52 +0100)
committerThomas Graf <tgraf@suug.ch>
Sat, 10 Nov 2012 09:52:26 +0000 (10:52 +0100)
The reference counter of the linked object must be dec'ed
before freeing the node or the reference is leaked.

Signed-off-by: Thomas Graf <tgraf@suug.ch>
lib/hashtable.c

index 5cea985ff115122942afa6a23c01dacd9bf91ce3..6a1e8f5a62efd9e3da1e220fddcf79e9dc04227f 100644 (file)
@@ -57,6 +57,8 @@ errout:
 /**
  * Free hashtable including all nodes
  * @arg ht             Hashtable
+ *
+ * @note Reference counter of all objects in the hashtable will be decremented.
  */
 void nl_hash_table_free(nl_hash_table_t *ht)
 {
@@ -69,6 +71,7 @@ void nl_hash_table_free(nl_hash_table_t *ht)
            while (node) {
                   saved_node = node;
                   node = node->next;
+                  nl_object_put(saved_node->obj);
                   free(saved_node);
            }
        }