diff options
author | Shauren <shauren.trinity@gmail.com> | 2012-02-29 20:12:11 +0100 |
---|---|---|
committer | Shauren <shauren.trinity@gmail.com> | 2012-02-29 20:12:11 +0100 |
commit | 03a7a806871a0447ec272151dd84421340b11d67 (patch) | |
tree | 3404187fa38dd7783cefa7b0d0d9007fca20f856 /src | |
parent | 3a4ec8a0b89d598b7586eda339d8b2ad07156a1a (diff) |
Core/Packets: Fixed exceptions being incorrectly thrown when appending empty strings to packets
Closes #5486
Closes #5495
Diffstat (limited to 'src')
-rw-r--r-- | src/server/shared/Packets/ByteBuffer.cpp | 22 | ||||
-rwxr-xr-x | src/server/shared/Packets/ByteBuffer.h | 12 |
2 files changed, 5 insertions, 29 deletions
diff --git a/src/server/shared/Packets/ByteBuffer.cpp b/src/server/shared/Packets/ByteBuffer.cpp deleted file mode 100644 index a64bb926d04..00000000000 --- a/src/server/shared/Packets/ByteBuffer.cpp +++ /dev/null @@ -1,22 +0,0 @@ -/* - * Copyright (C) 2008-2012 TrinityCore <http://www.trinitycore.org/> - * - * This program is free software; you can redistribute it and/or modify it - * under the terms of the GNU General Public License as published by the - * Free Software Foundation; either version 2 of the License, or (at your - * option) any later version. - * - * This program is distributed in the hope that it will be useful, but WITHOUT - * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or - * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for - * more details. - * - * You should have received a copy of the GNU General Public License along - * with this program. If not, see <http://www.gnu.org/licenses/>. - */ - -#include "ByteBuffer.h" - -void ByteBufferException::PrintError() const -{ -} diff --git a/src/server/shared/Packets/ByteBuffer.h b/src/server/shared/Packets/ByteBuffer.h index e6fdcf0f202..f018eb31bb4 100755 --- a/src/server/shared/Packets/ByteBuffer.h +++ b/src/server/shared/Packets/ByteBuffer.h @@ -178,14 +178,17 @@ class ByteBuffer ByteBuffer &operator<<(const std::string &value) { - append((uint8 const*)value.c_str(), value.length()); + if (size_t len = value.length()) + append((uint8 const*)value.c_str(), len); append((uint8)0); return *this; } ByteBuffer &operator<<(const char *str) { - append((uint8 const*)str, str ? strlen(str) : 0); + size_t len = 0; + if (str && (len = strlen(str))) + append((uint8 const*)str, len); append((uint8)0); return *this; } @@ -372,11 +375,6 @@ class ByteBuffer _storage.reserve(ressize); } - void append(const std::string& str) - { - append((uint8 const*)str.c_str(), str.size() + 1); - } - void append(const char *src, size_t cnt) { return append((const uint8 *)src, cnt); |