diff --git a/phpseclib/Net/SFTP.php b/phpseclib/Net/SFTP.php index 59c760ba..7165b57a 100644 --- a/phpseclib/Net/SFTP.php +++ b/phpseclib/Net/SFTP.php @@ -1257,6 +1257,9 @@ class Net_SFTP extends Net_SSH2 $temp = &$this->stat_cache; $max = count($dirs) - 1; foreach ($dirs as $i => $dir) { + if (!is_array($temp)) { + return false; + } if ($i === $max) { unset($temp[$dir]); return true; @@ -1283,6 +1286,9 @@ class Net_SFTP extends Net_SSH2 $temp = &$this->stat_cache; foreach ($dirs as $dir) { + if (!is_array($temp)) { + return null; + } if (!isset($temp[$dir])) { return null; }