Prechádzať zdrojové kódy

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 6 rokov pred
rodič
commit
8cfee2c872
1 zmenil súbory, kde vykonal 7 pridanie a 2 odobranie
  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
 }