Explorar o código

BETA: Null pointer access vulnerability fix:
* Related to pet name change and control item.
* Closing #5318
* Probably from forced database item delete.

Zoey76 %!s(int64=13) %!d(string=hai) anos
pai
achega
e210a9875b

+ 15 - 8
L2J_Server_BETA/java/com/l2jserver/gameserver/model/actor/instance/L2PetInstance.java

@@ -1372,15 +1372,22 @@ public class L2PetInstance extends L2Summon
 	@Override
 	public void setName(String name)
 	{
-		L2ItemInstance controlItem = getControlItem();
-		if (getControlItem().getCustomType2() == (name == null ? 1 : 0))
+		final L2ItemInstance controlItem = getControlItem();
+		if (controlItem != null)
 		{
-			// name not set yet
-			controlItem.setCustomType2(name != null ? 1 : 0);
-			controlItem.updateDatabase();
-			InventoryUpdate iu = new InventoryUpdate();
-			iu.addModifiedItem(controlItem);
-			sendPacket(iu);
+			if (controlItem.getCustomType2() == (name == null ? 1 : 0))
+			{
+				// name not set yet
+				controlItem.setCustomType2(name != null ? 1 : 0);
+				controlItem.updateDatabase();
+				InventoryUpdate iu = new InventoryUpdate();
+				iu.addModifiedItem(controlItem);
+				sendPacket(iu);
+			}
+		}
+		else
+		{
+			_log.log(Level.WARNING, "Pet control item null!");
 		}
 		super.setName(name);
 	}