Code:
	void Client::RepairInventory(){
	const Item_Struct* item = 0;
	int16 slotid = 0;
	for(int i=0;i<pp_containerinv_size;i++) {
		slotid = i;
		//Repair Main Inventory
		if(i<pp_inventory_size) {
			if(pp.inventory[slotid] == 0xFFFF) {
				//Nothing in slot, dont need to do anything
			}
			else {
				if(!(item = database.GetItem(pp.inventory[slotid]))) {
					//Item no longer exists, destroy it
					if(slotid == 0) {
						//Cursor
						pp.inventory[0] = 0xFFFF;
						memset(&pp.invitemproperties[0],0,sizeof(ItemProperties_Struct));
						for(int bag=0;bag<10;bag++) {
							int32 currentslot = 80+bag;
							memset(&pp.bagitemproperties[currentslot],0,sizeof(ItemProperties_Struct));
							pp.containerinv[currentslot] = 0xFFFF;
						}
					}
					else if(slotid >= 1 && slotid <= 21) {
						//Equipped Items
						pp.inventory[slotid] = 0xFFFF;
						memset(&pp.invitemproperties[slotid],0,sizeof(ItemProperties_Struct));
					}
					else if(slotid >= 22 && slotid <= 29) {
						//Main Inventory
						pp.inventory[slotid] = 0xFFFF;
						memset(&pp.invitemproperties[slotid],0,sizeof(ItemProperties_Struct));
									
						for(int bag=0;bag<10;bag++) {
							int32 currentslot = ((slotid-22)*10)+bag;
							memset(&pp.bagitemproperties[currentslot],0,sizeof(ItemProperties_Struct));
							pp.containerinv[currentslot] = 0xFFFF;
						}
					}
				}
				else {
					//Item exists, make sure it is ok
					if((item->IsGM() || !item->nosave) && admin < 10) {
						pp.inventory[0] = 0xFFFF;
						memset(&pp.invitemproperties[0],0,sizeof(ItemProperties_Struct));
						if(item->IsBag()) {
							if(slotid == 0) {
								for(int bag=0;bag<10;bag++){
									int32 currentslot = 80+bag;
									memset(&pp.bagitemproperties[currentslot],0,sizeof(ItemProperties_Struct));
									pp.containerinv[currentslot] = 0xFFFF;
								}
							}
							else if(slotid >= 22 && slotid <= 30) {
								for(int bag=0;bag<10;bag++){
									int32 currentslot = ((slotid-22)*10)+bag;
									memset(&pp.bagitemproperties[currentslot],0,sizeof(ItemProperties_Struct));
									pp.containerinv[currentslot] = 0xFFFF;
								}
							}
						}
						else {
							if(item->common.MaxCharges==255)
								pp.invitemproperties[slotid].charges = 255;
							else if(item->common.MaxCharges==0)
								pp.invitemproperties[slotid].charges = item->common.charges;
							memset(pp.invitemproperties[slotid].unknown01,0xFF,sizeof(int8)*2);
							memset(pp.invitemproperties[slotid].unknown02,0xFF,sizeof(int8)*6);
						}
					}
				}
			}
			//End of Repairing Main Inventory
			//Repair Container Inventory
			if(i<pp_containerinv_size) {
				if(pp.containerinv[slotid] == 0xFFFF) {
					//Nothing in slot, don't do anything
				}
				else {
					if(!(item = database.GetItem(pp.containerinv[slotid]))) {
						//Item no longer exists, destroy it
						pp.containerinv[slotid] = 0xFFFF;
						memset(&pp.bagitemproperties[slotid],0,sizeof(ItemProperties_Struct));
					}
					else {
						//Item exists, make sure it is ok
						if((item->IsGM() || !item->nosave) && admin < 10) {
							pp.containerinv[slotid] = 0xFFFF;
							memset(&pp.bagitemproperties[slotid],0,sizeof(ItemProperties_Struct));
						}
						else {
							if(item->common.MaxCharges==255)
								pp.bagitemproperties[slotid].charges = 255;
							else if(item->common.MaxCharges==0)
								pp.bagitemproperties[slotid].charges = item->common.charges;
							memset(pp.bagitemproperties[slotid].unknown01,0xFF,sizeof(int8)*2);
							memset(pp.bagitemproperties[slotid].unknown02,0xFF,sizeof(int8)*6);
						}
					}
				}
			}
		}
		//End of Repairing Container Inventory
		if(i<pp_bank_inv_size) {
			if(!(item = database.GetItem(pp.bank_inv[slotid]))){
				//Item no longer exists, destroy it
				pp.bank_inv[slotid] = 0xFFFF;
				memset(&pp.bankinvitemproperties[slotid],0,sizeof(ItemProperties_Struct));
			}
			else {
				//Item exists, make sure it is ok
				if((item->IsGM() || !item->nosave) && admin < 10) {
					pp.bank_inv[slotid] = 0xFFFF;
					memset(&pp.bankinvitemproperties[slotid],0,sizeof(ItemProperties_Struct));
					for(int bag=0;bag<10;bag++){
						int32 currentslot = bag+slotid;
						memcpy(&pp.bankbagitemproperties[currentslot],0,sizeof(ItemProperties_Struct));
						pp.bank_cont_inv[currentslot] = 0xFFFF;
					}
				}
				else {
					if(item->common.MaxCharges==255)
						pp.bankinvitemproperties[slotid].charges = 255;
					else if(item->common.MaxCharges==0)
						pp.bankinvitemproperties[slotid].charges = item->common.charges;
					memset(pp.bankinvitemproperties[slotid].unknown01,0xFF,sizeof(int8)*2);
					memset(pp.bankinvitemproperties[slotid].unknown02,0xFF,sizeof(int8)*6);
				}
			}
		}
		if(i<pp_bank_cont_inv_size) {
			if(!(item = database.GetItem(pp.bank_cont_inv[slotid]))){
				//Item no longer exists, destroy it
				pp.bank_cont_inv[slotid] = 0xFFFF;
				memset(&pp.bankbagitemproperties[slotid],0,sizeof(ItemProperties_Struct));
			}
			else {
				//Item exists, make sure it is ok
				if((item->IsGM() || !item->nosave) && admin < 10) {
					pp.bank_cont_inv[slotid] = 0xFFFF;
					memset(&pp.bankbagitemproperties[slotid],0,sizeof(ItemProperties_Struct));
				}
				else {
					if(item->common.MaxCharges==255)
						pp.bankbagitemproperties[slotid].charges = 255;
					else if(item->common.MaxCharges==0)
						pp.bankbagitemproperties[slotid].charges = item->common.charges;
					memset(pp.bankbagitemproperties[slotid].unknown01,0xFF,sizeof(int8)*2);
					memset(pp.bankbagitemproperties[slotid].unknown02,0xFF,sizeof(int8)*6);
				}
			}
		}
	}
}
 This code fixes several memcpys to memsets so that the zone server no longer crashes when there is something wrong with inventory.