From ad3a2c6f3f3a583c75c186374ca57d0bcedcc193 Mon Sep 17 00:00:00 2001 From: Jon Stovell Date: Thu, 13 Aug 2026 19:45:40 -0600 Subject: [PATCH] Correctly handles unit-less values in memoryReturnBytes() Signed-off-by: Jon Stovell --- Sources/Subs.php | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/Sources/Subs.php b/Sources/Subs.php index f8881a8c30..5f24c21373 100644 --- a/Sources/Subs.php +++ b/Sources/Subs.php @@ -4508,11 +4508,11 @@ function setMemoryLimit($needed, $in_use = false) function memoryReturnBytes($val) { if (is_integer($val)) - return $val; + return $val < 0 ? PHP_INT_MAX : $val; // Separate the number from the designator $val = trim($val); - $num = intval(substr($val, 0, strlen($val) - 1)); + $num = (int) $val; $last = strtolower(substr($val, -1)); // convert to bytes @@ -4525,7 +4525,7 @@ function memoryReturnBytes($val) case 'k': $num *= 1024; } - return $num; + return $num < 0 ? PHP_INT_MAX : $num; } /**