diff options
Diffstat (limited to 'src/packet.cpp')
-rw-r--r-- | src/packet.cpp | 8 |
1 files changed, 6 insertions, 2 deletions
diff --git a/src/packet.cpp b/src/packet.cpp index 9ab27d84..6664235f 100644 --- a/src/packet.cpp +++ b/src/packet.cpp @@ -37,11 +37,15 @@ Packet::Packet(const char *data, int length): Packet::~Packet() { // Clean up the data - delete[] data; + if (data) + delete[] data; } void Packet::expand(unsigned int bytes) { - realloc(data, length + bytes); + char *newData = (char*)malloc(length + bytes); + memcpy(newData, (void*)data, length); + delete []data; + data = newData; size += bytes; } |