diff options
author | Matthew Cline <zelgadis@sourceforge.net> | 2009-11-10 03:10:00 -0800 |
---|---|---|
committer | Matthew Cline <zelgadis@sourceforge.net> | 2009-11-10 03:11:44 -0800 |
commit | eba5fc84b75c7dde072f1ba49a56f5e7913b8eb7 (patch) | |
tree | 7530361adfb726edbfca62259cc09d6610bd7ca7 /crawl-ref/source/store.cc | |
parent | 1569a7ec6ccfc1d9aafe1a92c70bba132adf6bf7 (diff) | |
download | crawl-ref-eba5fc84b75c7dde072f1ba49a56f5e7913b8eb7.tar.gz crawl-ref-eba5fc84b75c7dde072f1ba49a56f5e7913b8eb7.zip |
CrawlHashTable: free memory on assignment
Free a CrawlHashTable's used memory when it's clobbered via being
assigned to.
Diffstat (limited to 'crawl-ref/source/store.cc')
-rw-r--r-- | crawl-ref/source/store.cc | 5 |
1 files changed, 4 insertions, 1 deletions
diff --git a/crawl-ref/source/store.cc b/crawl-ref/source/store.cc index 97d1e0a8c1..25c50ed763 100644 --- a/crawl-ref/source/store.cc +++ b/crawl-ref/source/store.cc @@ -1154,7 +1154,7 @@ CrawlHashTable::CrawlHashTable(const CrawlHashTable& other) CrawlHashTable::~CrawlHashTable() { - // NOTE: Not using std::auto_ptr because making hash_map and auto_ptr + // NOTE: Not using std::auto_ptr because making hash_map an auto_ptr // causes compile weirdness in externs.h if (hash_map == NULL) return; @@ -1165,6 +1165,9 @@ CrawlHashTable::~CrawlHashTable() CrawlHashTable &CrawlHashTable::operator = (const CrawlHashTable &other) { + if (hash_map != NULL) + delete hash_map; + if (other.hash_map == NULL) { hash_map = NULL; |