summaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authorErik Schilling <ablu.erikschilling@gmail.com>2015-04-24 17:28:57 +0200
committerErik Schilling <ablu.erikschilling@gmail.com>2015-04-24 17:28:57 +0200
commit1518b8f914c389538b2efcaba3bce64707278b74 (patch)
tree94c3983a51e48b9ec8b04fdb05fd842b970e3aed /src
parente24b21b8b210bc01f7033d67b284731d221a4871 (diff)
downloadmanaserv-1518b8f914c389538b2efcaba3bce64707278b74.tar.gz
manaserv-1518b8f914c389538b2efcaba3bce64707278b74.tar.bz2
manaserv-1518b8f914c389538b2efcaba3bce64707278b74.tar.xz
manaserv-1518b8f914c389538b2efcaba3bce64707278b74.zip
Fix crash if the client sends garbage public id values
Indexing an array with a negative int as index is no good idea...
Diffstat (limited to 'src')
-rw-r--r--src/game-server/mapcomposite.cpp6
1 files changed, 5 insertions, 1 deletions
diff --git a/src/game-server/mapcomposite.cpp b/src/game-server/mapcomposite.cpp
index deb43b4e..41073b3c 100644
--- a/src/game-server/mapcomposite.cpp
+++ b/src/game-server/mapcomposite.cpp
@@ -403,12 +403,16 @@ void MapContent::deallocate(Entity *obj)
*/
Entity *MapContent::findEntityById(int publicId) const
{
+ if (publicId < 0) {
+ return nullptr;
+ }
+
if (ObjectBucket *b = buckets[publicId / 256]) {
const int bucketIndex = publicId % 256;
if (b->isAllocated(bucketIndex))
return b->objects[bucketIndex];
}
- return 0;
+ return nullptr;
}
static void addZone(MapRegion &r, unsigned z)