aboutsummaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authorjackpoz <giacomopoz@gmail.com>2014-04-13 15:01:20 +0200
committerjackpoz <giacomopoz@gmail.com>2014-04-13 15:01:20 +0200
commit9d5841073971c7f55cf621da3a31b38656618582 (patch)
treecc128f0cb363d154ea470b1f443f2d1e8a9cefac /src
parentdc58ec0d6c4d33e04b74a5ca43340941bcab331c (diff)
Scripts/Commands: Fix memory leak in ".gobject add" command
Valgrind log: 158 (104 direct, 54 indirect) bytes in 1 blocks are definitely lost in loss record 24 of 73 at operator new(unsigned long) (vg_replace_malloc.c:319) by GameObjectModel::Create(GameObject const&) (GameObjectModel.cpp:152) by GameObject::Create(unsigned int, unsigned int, Map*, unsigned int, float, float, float, float, float, float, float, float, unsigned int, GOState, unsigned int) (GameObject.cpp:237) by gobject_commandscript::HandleGameObjectAddCommand(ChatHandler*, char const*) (cs_gobject.cpp:155)
Diffstat (limited to 'src')
-rw-r--r--src/server/scripts/Commands/cs_gobject.cpp2
1 files changed, 2 insertions, 0 deletions
diff --git a/src/server/scripts/Commands/cs_gobject.cpp b/src/server/scripts/Commands/cs_gobject.cpp
index 62a61ff741b..5c49a0e92c9 100644
--- a/src/server/scripts/Commands/cs_gobject.cpp
+++ b/src/server/scripts/Commands/cs_gobject.cpp
@@ -166,7 +166,9 @@ public:
// fill the gameobject data and save to the db
object->SaveToDB(map->GetId(), (1 << map->GetSpawnMode()), player->GetPhaseMaskForSpawn());
+ delete object;
+ object = new GameObject();
// this will generate a new guid if the object is in an instance
if (!object->LoadGameObjectFromDB(guidLow, map))
{