From 07adadcb58aafbaf784e8caf46268c09faa33e2e Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Florian=20Mei=C3=9Fner?= Date: Thu, 5 Dec 2013 22:20:12 +0100 Subject: [PATCH] Fix out-of-bounds crash when fiddling with NPCs --- Sources/Plasma/PubUtilLib/plNetClient/plNetClientMgr.cpp | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/Sources/Plasma/PubUtilLib/plNetClient/plNetClientMgr.cpp b/Sources/Plasma/PubUtilLib/plNetClient/plNetClientMgr.cpp index a8315d5a..e536afd0 100644 --- a/Sources/Plasma/PubUtilLib/plNetClient/plNetClientMgr.cpp +++ b/Sources/Plasma/PubUtilLib/plNetClient/plNetClientMgr.cpp @@ -784,7 +784,9 @@ plSynchedObject* plNetClientMgr::GetLocalPlayer(bool forceLoad) const plSynchedObject* plNetClientMgr::GetNPC(uint32_t i) const { - return fNPCKeys[i] ? plSynchedObject::ConvertNoRef(fNPCKeys[i]->ObjectIsLoaded()) : nil; + if (i >= fNPCKeys.size()) + return nullptr; + return plSynchedObject::ConvertNoRef(fNPCKeys[i]->ObjectIsLoaded()); } void plNetClientMgr::AddNPCKey(const plKey& npc)