Explorar o código

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!
Aleos %!s(int64=6) %!d(string=hai) anos
pai
achega
8cfee2c872
Modificáronse 1 ficheiros con 7 adicións e 2 borrados
  1. 7 2
      src/map/clif.cpp

+ 7 - 2
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
 }