aboutsummaryrefslogtreecommitdiff
path: root/src/itemdef.cpp
diff options
context:
space:
mode:
authorPerttu Ahola <celeron55@gmail.com>2012-03-20 17:55:34 +0200
committerPerttu Ahola <celeron55@gmail.com>2012-03-20 17:55:34 +0200
commitc0530921ffac89c2249500ba0a1bddd9d288cfbe (patch)
treec662c1b8872067160b4dac3fd84b553cd7093737 /src/itemdef.cpp
parent94f1ab4da3296be707f9164d7a2f7cd61e357e12 (diff)
downloadminetest-c0530921ffac89c2249500ba0a1bddd9d288cfbe.tar.gz
minetest-c0530921ffac89c2249500ba0a1bddd9d288cfbe.tar.bz2
minetest-c0530921ffac89c2249500ba0a1bddd9d288cfbe.zip
Attempt to fix some minor memory leaks
Diffstat (limited to 'src/itemdef.cpp')
-rw-r--r--src/itemdef.cpp7
1 files changed, 5 insertions, 2 deletions
diff --git a/src/itemdef.cpp b/src/itemdef.cpp
index a646134af..934150aa1 100644
--- a/src/itemdef.cpp
+++ b/src/itemdef.cpp
@@ -290,8 +290,11 @@ public:
// Ensure that the "" item (the hand) always has ToolCapabilities
if(def.name == "")
assert(def.tool_capabilities != NULL);
-
- m_item_definitions[def.name] = new ItemDefinition(def);
+
+ if(m_item_definitions.count(def.name) == 0)
+ m_item_definitions[def.name] = new ItemDefinition(def);
+ else
+ *(m_item_definitions[def.name]) = def;
// Remove conflicting alias if it exists
bool alias_removed = (m_aliases.erase(def.name) != 0);