From 8cfee2c872c854e716a8e266ad89d14a1724fd6a Mon Sep 17 00:00:00 2001 From: Aleos Date: Mon, 3 Jun 2019 09:04:25 -0400 Subject: [PATCH] Corrected a potential crash from equip switch (#4198) * Resolves a potential crash with the equip switch feature and invalid items. Thanks to Melvo and @functor-x! --- src/map/clif.cpp | 9 +++++++-- 1 file changed, 7 insertions(+), 2 deletions(-) diff --git a/src/map/clif.cpp b/src/map/clif.cpp index 6444034c2e..adeeea3768 100644 --- a/src/map/clif.cpp +++ b/src/map/clif.cpp @@ -20869,6 +20869,10 @@ void clif_parse_equipswitch_request_single( int fd, struct map_session_data* sd return; } + // Check if the item exists + if (sd->inventory_data[index] == nullptr) + return; + // Check if the item was already added to equip switch if( sd->inventory.u.items_inventory[index].equipSwitch ){ if( sd->npc_id ){ @@ -20884,9 +20888,10 @@ void clif_parse_equipswitch_request_single( int fd, struct map_session_data* sd } pc_equipswitch( sd, index ); - }else{ - pc_equipitem( sd, index, pc_equippoint(sd, index), true ); + return; } + + pc_equipitem( sd, index, pc_equippoint(sd, index), true ); #endif }