Commit 97390ee5 authored by Jürg Billeter's avatar Jürg Billeter
Browse files

gee: Fix memory leak in HashMap.remove and HashSet.remove

Fixes bug 584440.
parent 780e79f6
......@@ -116,9 +116,14 @@ public class Gee.HashMap<K,V> : Object, Map<K,V> {
public bool remove (K key) {
Node<K,V>** node = lookup_node (key);
if (*node != null) {
Node<K,V> next = (owned) (*node)->next;
(*node)->key = null;
(*node)->value = null;
*node = (*node)->next;
delete *node;
*node = (owned) next;
_nnodes--;
resize ();
_stamp++;
......
......@@ -102,8 +102,13 @@ public class Gee.HashSet<G> : Object, Iterable<G>, Collection<G>, Set<G> {
public bool remove (G key) {
Node<G>** node = lookup_node (key);
if (*node != null) {
Node<G> next = (owned) (*node)->next;
(*node)->key = null;
*node = (*node)->next;
delete *node;
*node = (owned) next;
_nnodes--;
resize ();
_stamp++;
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment