aboutsummaryrefslogtreecommitdiff
path: root/src/server/shared/Database/Field.cpp
diff options
context:
space:
mode:
authorMachiavelli <none@none>2010-09-25 13:12:12 +0200
committerMachiavelli <none@none>2010-09-25 13:12:12 +0200
commit477b30a1adb6acb5e0f6df22061bf45f109204a3 (patch)
tree1859aa31cb4fe7a60c9ae5d1e6aad42f449d982e /src/server/shared/Database/Field.cpp
parent0fa7d24637613c376586f575bc54337905ff109e (diff)
Core/DBLayer: Fix a memory leak in Field class, properly clear buffer before repopulating it.
Fixes many issues (from wrong subnames on NPCs to absent GO/Creature spawns) Thanks to Rat for helping find the issue --HG-- branch : trunk
Diffstat (limited to 'src/server/shared/Database/Field.cpp')
-rw-r--r--src/server/shared/Database/Field.cpp10
1 files changed, 8 insertions, 2 deletions
diff --git a/src/server/shared/Database/Field.cpp b/src/server/shared/Database/Field.cpp
index 7afcbdfedaf..552b93b42da 100644
--- a/src/server/shared/Database/Field.cpp
+++ b/src/server/shared/Database/Field.cpp
@@ -32,10 +32,13 @@ Field::~Field()
void Field::SetByteValue(const void* newValue, const size_t newSize, enum_field_types newType, uint32 length)
{
+ if (data.value)
+ CleanUp();
+
// This value stores raw bytes that have to be explicitly casted later
if (newValue)
{
- data.value = new char [newSize];
+ data.value = new char[newSize];
memcpy(data.value, newValue, newSize);
data.length = length;
}
@@ -43,8 +46,11 @@ void Field::SetByteValue(const void* newValue, const size_t newSize, enum_field_
data.raw = true;
}
-void Field::SetStructuredValue(char* newValue, enum_field_types newType, const size_t newSize)
+void Field::SetStructuredValue(char* newValue, enum_field_types newType)
{
+ if (data.value)
+ CleanUp();
+
// This value stores somewhat structured data that needs function style casting
if (newValue)
{