mirror of
https://github.com/pmmp/PocketMine-MP.git
synced 2025-09-06 09:56:06 +00:00
Make use of Utils::assumeNotFalse() in a bunch of places
I've stuck to only doing this in the places where I'm sure we should never get false back. Other places I'm less sure of (and I found more bugs along the way).
This commit is contained in:
@ -25,6 +25,7 @@ namespace pocketmine\resourcepacks;
|
||||
|
||||
use Ahc\Json\Comment as CommentedJsonDecoder;
|
||||
use pocketmine\resourcepacks\json\Manifest;
|
||||
use pocketmine\utils\Utils;
|
||||
use function assert;
|
||||
use function fclose;
|
||||
use function feof;
|
||||
@ -73,7 +74,7 @@ class ZippedResourcePack implements ResourcePack{
|
||||
$manifestPath = null;
|
||||
$manifestIdx = null;
|
||||
for($i = 0; $i < $archive->numFiles; ++$i){
|
||||
$name = $archive->getNameIndex($i);
|
||||
$name = Utils::assumeNotFalse($archive->getNameIndex($i), "This index should be valid");
|
||||
if(
|
||||
($manifestPath === null or strlen($name) < strlen($manifestPath)) and
|
||||
preg_match('#.*/manifest.json$#', $name) === 1
|
||||
@ -156,6 +157,6 @@ class ZippedResourcePack implements ResourcePack{
|
||||
if(feof($this->fileResource)){
|
||||
throw new \InvalidArgumentException("Requested a resource pack chunk with invalid start offset");
|
||||
}
|
||||
return fread($this->fileResource, $length);
|
||||
return Utils::assumeNotFalse(fread($this->fileResource, $length), "Already checked that we're not at EOF");
|
||||
}
|
||||
}
|
||||
|
Reference in New Issue
Block a user