Merge pull request #50 from dongresource/bugfix

Fix crash when receiving invalid packets with very low ids.
This commit is contained in:
CPunch 2020-08-26 15:33:23 -05:00 committed by GitHub
commit 64d4b1d26a
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
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);