aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorFilippos Karapetis2013-12-14 04:16:55 +0200
committerFilippos Karapetis2013-12-17 01:16:28 +0200
commitb585addc23de25c019f250986d50c0373219571d (patch)
treea965d0af7a3e5410f00cdb643dffcb96b732cc61
parent9466f57978619ee96b00b57e927548b25d916074 (diff)
downloadscummvm-rg350-b585addc23de25c019f250986d50c0373219571d.tar.gz
scummvm-rg350-b585addc23de25c019f250986d50c0373219571d.tar.bz2
scummvm-rg350-b585addc23de25c019f250986d50c0373219571d.zip
COMMON: Fix mismatched new/delete in the MemoryPool class
Memory is allocated with new in Hashmap::allocNode() and incorrectly freed with free() in ~MemoryPool() and freeUnusedPages(). Issue reported by Dr. Memory
-rw-r--r--common/memorypool.cpp4
1 files changed, 2 insertions, 2 deletions
diff --git a/common/memorypool.cpp b/common/memorypool.cpp
index e3742eeae0..3a31fd55ea 100644
--- a/common/memorypool.cpp
+++ b/common/memorypool.cpp
@@ -56,7 +56,7 @@ MemoryPool::~MemoryPool() {
#endif
for (size_t i = 0; i < _pages.size(); ++i)
- ::free(_pages[i].start);
+ delete _pages[i].start;
}
void MemoryPool::allocPage() {
@@ -152,7 +152,7 @@ void MemoryPool::freeUnusedPages() {
iter2 = *(void ***)iter2;
}
- ::free(_pages[i].start);
+ delete _pages[i].start;
++freedPagesCount;
_pages[i].start = NULL;
}