From 7baf65938a92d23cd36c447cb9c706e6b51b04f4 Mon Sep 17 00:00:00 2001 From: Graham Campbell Date: Sun, 29 Dec 2019 14:34:04 +0000 Subject: [PATCH] Robust getStreamSize --- src/Util.php | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/src/Util.php b/src/Util.php index 9de37775f..c1e9fc395 100644 --- a/src/Util.php +++ b/src/Util.php @@ -273,6 +273,10 @@ public static function getStreamSize($resource) { $stat = fstat($resource); + if ( ! is_array($stat) || ! isset($stat['size'])) { + throw new RuntimeException('Cannot stat resource. Remote files are not supported.'); + } + return $stat['size']; }