diff options
author | Johannes Schickel | 2008-11-07 13:42:05 +0000 |
---|---|---|
committer | Johannes Schickel | 2008-11-07 13:42:05 +0000 |
commit | 4cc5015fd024bfd9f144d1961688ad3202906d38 (patch) | |
tree | 802abc0d5fd2f735237d9cca9c7790b05b4ae7b9 /common/archive.cpp | |
parent | 1512fbd261e229c4d95f70cc5061f105a1ac7a0f (diff) | |
download | scummvm-rg350-4cc5015fd024bfd9f144d1961688ad3202906d38.tar.gz scummvm-rg350-4cc5015fd024bfd9f144d1961688ad3202906d38.tar.bz2 scummvm-rg350-4cc5015fd024bfd9f144d1961688ad3202906d38.zip |
Fixed leak when using SearchSet::add for an already existing name.
svn-id: r34928
Diffstat (limited to 'common/archive.cpp')
-rw-r--r-- | common/archive.cpp | 8 |
1 files changed, 5 insertions, 3 deletions
diff --git a/common/archive.cpp b/common/archive.cpp index 4b1ecd8a6d..36687d4ec5 100644 --- a/common/archive.cpp +++ b/common/archive.cpp @@ -299,17 +299,19 @@ void SearchSet::insert(const Node &node) { _list.insert(it, node); } -void SearchSet::add(const String& name, Archive *archive, int priority, bool autoFree) { +void SearchSet::add(const String &name, Archive *archive, int priority, bool autoFree) { if (find(name) == _list.end()) { Node node(priority, name, archive, autoFree); insert(node); } else { + if (autoFree) + delete archive; warning("SearchSet::add: archive '%s' already present", name.c_str()); } } -void SearchSet::remove(const String& name) { +void SearchSet::remove(const String &name) { ArchiveList::iterator it = find(name); if (it != _list.end()) { if (it->_autoFree) @@ -331,7 +333,7 @@ void SearchSet::clear() { _list.clear(); } -void SearchSet::setPriority(const String& name, int priority) { +void SearchSet::setPriority(const String &name, int priority) { ArchiveList::iterator it = find(name); if (it == _list.end()) { warning("SearchSet::setPriority: archive '%s' is not present", name.c_str()); |