From 75b01f669a88bae2c7014ce9b10c651c1d7ebcd5 Mon Sep 17 00:00:00 2001 From: Marek Bachmann Date: Wed, 30 Nov 2022 04:35:18 +0100 Subject: [PATCH] Check for inf values before try to converts bytes to binary prefix strings --- src/Util/Strings.php | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/src/Util/Strings.php b/src/Util/Strings.php index 5988cc89b..e1ec4ae50 100644 --- a/src/Util/Strings.php +++ b/src/Util/Strings.php @@ -220,6 +220,11 @@ class Strings */ public static function formatBytes(int $bytes, int $precision = 2): string { + // If this method is called for an infinite (== unlimited) amount of bytes: + if ($bytes == INF) { + return INF; + } + $units = ['B', 'KB', 'MB', 'GB', 'TB']; $bytes = max($bytes, 0); $pow = floor(($bytes ? log($bytes) : 0) / log(1024));