Fix crash when receiving invalid packets with very low ids.

Also fix benign NPC deallocation bug.
This commit is contained in:
dongresource 2020-08-26 22:22:52 +02:00
parent e0c00bcdc8
commit 9b0cb7f441
2 changed files with 4 additions and 4 deletions

View File

@ -204,13 +204,13 @@ std::string Defines::p2str(int type, int val) {
switch (type) { switch (type) {
case CL2LS: case CL2LS:
val = val - CL2LS - 1; val = val - CL2LS - 1;
if (val > N_CL2LS) if (val > N_CL2LS || val < 0)
break; break;
return cl2ls_map[val].name; return cl2ls_map[val].name;
case CL2FE: case CL2FE:
val = val - CL2FE - 1; val = val - CL2FE - 1;
if (val > N_CL2FE) if (val > N_CL2FE || val < 0)
break; break;
return cl2fe_map[val].name; return cl2fe_map[val].name;

View File

@ -106,9 +106,9 @@ void NPCManager::updatePlayerNPCS(CNSocket* sock, PlayerView& view) {
// remove from view // remove from view
view.viewableNPCs.erase(i++); view.viewableNPCs.erase(i++);
} else {
i++;
} }
++i;
} }
INITSTRUCT(sP_FE2CL_NPC_ENTER, enterData); INITSTRUCT(sP_FE2CL_NPC_ENTER, enterData);