RCON: properly handle potential errors during socket setup

This commit is contained in:
Dylan K. Taylor
2020-04-16 01:29:28 +01:00
parent 63b109f23e
commit 619a9892e5
2 changed files with 10 additions and 3 deletions

View File

@ -25,6 +25,7 @@ namespace pocketmine\level\format\io\region;
use pocketmine\level\format\ChunkException;
use pocketmine\level\format\io\exception\CorruptedChunkException;
use pocketmine\utils\AssumptionFailedError;
use pocketmine\utils\Binary;
use pocketmine\utils\MainLogger;
use function ceil;
@ -98,7 +99,9 @@ class RegionLoader{
throw new CorruptedRegionException("Region file should be padded to a multiple of 4KiB");
}
$this->filePointer = fopen($this->filePath, "r+b");
$filePointer = fopen($this->filePath, "r+b");
if($filePointer === false) throw new AssumptionFailedError("fopen() should not fail here");
$this->filePointer = $filePointer;
stream_set_read_buffer($this->filePointer, 1024 * 16); //16KB
stream_set_write_buffer($this->filePointer, 1024 * 16); //16KB
if(!$exists){