aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorMax Horn2007-03-09 16:19:50 +0000
committerMax Horn2007-03-09 16:19:50 +0000
commit6d9cb5498f5357e27098cc68c6c33076cbee654f (patch)
tree2493d123e069bfcf3881b07e8b4b8482f840a393
parent7a10fa72836b9511ee079e28755d30a4dc3c189a (diff)
downloadscummvm-rg350-6d9cb5498f5357e27098cc68c6c33076cbee654f.tar.gz
scummvm-rg350-6d9cb5498f5357e27098cc68c6c33076cbee654f.tar.bz2
scummvm-rg350-6d9cb5498f5357e27098cc68c6c33076cbee654f.zip
Avoid double frees in HashMap::erase
svn-id: r26040
-rw-r--r--common/hashmap.h4
1 files changed, 2 insertions, 2 deletions
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<Key, Val, HashFunc, EqualFunc>::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<Key, Val, HashFunc, EqualFunc>::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;
}