From abf8081ebcbb31c044188f7e7fda5496828ea852 Mon Sep 17 00:00:00 2001 From: "Dylan K. Taylor" Date: Mon, 2 Dec 2019 08:21:42 +0000 Subject: [PATCH] RuntimeBlockMapping: add a type check for decoded NBT root type this is kinda redundant since this function can blow up in so many other ways anyway, but it makes PHPStan happy, so it'll do. --- .../network/mcpe/protocol/types/RuntimeBlockMapping.php | 3 +++ 1 file changed, 3 insertions(+) diff --git a/src/pocketmine/network/mcpe/protocol/types/RuntimeBlockMapping.php b/src/pocketmine/network/mcpe/protocol/types/RuntimeBlockMapping.php index 03a383e698..ccb92e6e34 100644 --- a/src/pocketmine/network/mcpe/protocol/types/RuntimeBlockMapping.php +++ b/src/pocketmine/network/mcpe/protocol/types/RuntimeBlockMapping.php @@ -53,6 +53,9 @@ final class RuntimeBlockMapping{ public static function init() : void{ $legacyIdMap = json_decode(file_get_contents(\pocketmine\RESOURCE_PATH . "vanilla/block_id_map.json"), true); $tag = (new BigEndianNBTStream())->read(file_get_contents(\pocketmine\RESOURCE_PATH . "vanilla/runtime_block_states.dat")); + if(!($tag instanceof CompoundTag)){ //this is a little redundant currently, but good for auto complete and makes phpstan happy + throw new \RuntimeException("Invalid blockstates table, expected CompoundTag root"); + } $decompressed = [];