From: Marek Bachmann Date: Wed, 30 Nov 2022 03:35:18 +0000 (+0100) Subject: Check for inf values before try to converts bytes to binary prefix strings X-Git-Url: https://git.mxchange.org/?a=commitdiff_plain;h=75b01f669a88bae2c7014ce9b10c651c1d7ebcd5;p=friendica.git Check for inf values before try to converts bytes to binary prefix strings --- diff --git a/src/Util/Strings.php b/src/Util/Strings.php index 5988cc89bc..e1ec4ae50b 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));