From 1755b25808759daef5f93409b4c027d83912c6ef Mon Sep 17 00:00:00 2001 From: "Dylan K. Taylor" Date: Wed, 15 Apr 2020 12:13:26 +0100 Subject: [PATCH] Utils: make explicit assumption about result of scandir() in recursiveUnlink() TODO: this assumption might be flawed in the case of threading... --- src/pocketmine/utils/Utils.php | 1 + 1 file changed, 1 insertion(+) diff --git a/src/pocketmine/utils/Utils.php b/src/pocketmine/utils/Utils.php index 6649ded34a..fd99fba1c6 100644 --- a/src/pocketmine/utils/Utils.php +++ b/src/pocketmine/utils/Utils.php @@ -676,6 +676,7 @@ class Utils{ public static function recursiveUnlink(string $dir) : void{ if(is_dir($dir)){ $objects = scandir($dir, SCANDIR_SORT_NONE); + if($objects === false) throw new AssumptionFailedError("scandir() shouldn't return false when is_dir() returns true"); foreach($objects as $object){ if($object !== "." and $object !== ".."){ if(is_dir($dir . "/" . $object)){