From 2603f5cc6384c4ff685a7a340f280cf9a98d449d Mon Sep 17 00:00:00 2001 From: "Dylan K. Taylor" Date: Fri, 1 Sep 2017 20:22:02 +0100 Subject: [PATCH] Fixed RakLib crashing when exceptions are thrown in packet handlers after the player was closed This occurred if the player happened to be closed during the packet being handled, and then an uncaught exception bubbled up to the RakLibInterface. This resulted in a crash due to trying to get the address of a player who no longer had a network session, in order to block their IP address. --- src/pocketmine/network/mcpe/RakLibInterface.php | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/src/pocketmine/network/mcpe/RakLibInterface.php b/src/pocketmine/network/mcpe/RakLibInterface.php index 4d0dc92f7..4e8245253 100644 --- a/src/pocketmine/network/mcpe/RakLibInterface.php +++ b/src/pocketmine/network/mcpe/RakLibInterface.php @@ -133,6 +133,8 @@ class RakLibInterface implements ServerInstance, AdvancedSourceInterface{ public function handleEncapsulated($identifier, EncapsulatedPacket $packet, $flags){ if(isset($this->players[$identifier])){ + //get this now for blocking in case the player was closed before the exception was raised + $address = $this->players[$identifier]->getAddress(); try{ if($packet->buffer !== ""){ $pk = $this->getPacket($packet->buffer); @@ -143,7 +145,7 @@ class RakLibInterface implements ServerInstance, AdvancedSourceInterface{ $logger->debug("Packet " . (isset($pk) ? get_class($pk) : "unknown") . " 0x" . bin2hex($packet->buffer)); $logger->logException($e); - $this->interface->blockAddress($this->players[$identifier]->getAddress(), 5); + $this->interface->blockAddress($address, 5); } } }