From 9d5841073971c7f55cf621da3a31b38656618582 Mon Sep 17 00:00:00 2001 From: jackpoz Date: Sun, 13 Apr 2014 15:01:20 +0200 Subject: 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) --- src/server/scripts/Commands/cs_gobject.cpp | 2 ++ 1 file changed, 2 insertions(+) (limited to 'src') 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)) { -- cgit v1.2.3