From 6d9cb5498f5357e27098cc68c6c33076cbee654f Mon Sep 17 00:00:00 2001 From: Max Horn Date: Fri, 9 Mar 2007 16:19:50 +0000 Subject: Avoid double frees in HashMap::erase svn-id: r26040 --- common/hashmap.h | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) (limited to 'common') diff --git a/common/hashmap.h b/common/hashmap.h index d1c4bea0ee..b5b2bb922b 100644 --- a/common/hashmap.h +++ b/common/hashmap.h @@ -429,6 +429,8 @@ void HashMap::erase(const Key &key) { // If we remove a key, we must check all subsequent keys and possibly // reinsert them. uint j = i; + delete _arr[i]; + _arr[i] = NULL; while (true) { // Look at the next table slot j = (j + 1) % _arrsize; @@ -440,12 +442,10 @@ void HashMap::erase(const Key &key) { uint k = _hash(_arr[j]->_key) % _arrsize; if ((j > i && (k <= i || k > j)) || (j < i && (k <= i && k > j)) ) { - delete _arr[i]; _arr[i] = _arr[j]; i = j; } } - delete _arr[i]; _arr[i] = NULL; return; } -- cgit v1.2.3