]> git.mxchange.org Git - friendica.git/commitdiff
Check for inf values before try to converts bytes to binary prefix strings
authorMarek Bachmann <marek.bachmann@comtec.eecs.uni-kassel.de>
Wed, 30 Nov 2022 03:35:18 +0000 (04:35 +0100)
committerMarek Bachmann <marek.bachmann@comtec.eecs.uni-kassel.de>
Wed, 30 Nov 2022 03:35:18 +0000 (04:35 +0100)
src/Util/Strings.php

index 5988cc89bcef708f8c3907c890447d3c6677e17b..e1ec4ae50b456b468223e4b9a5a07e53f44a161c 100644 (file)
@@ -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));