diff options
| author | Stefan Boberg <[email protected]> | 2021-10-07 13:55:59 +0200 |
|---|---|---|
| committer | Stefan Boberg <[email protected]> | 2021-10-07 13:55:59 +0200 |
| commit | d4b7afefef2034920f1e8027af2ce292b7510592 (patch) | |
| tree | a71ef5cc7ee695bdb5dd59b32d9b1ca04544985c /zencore/string.cpp | |
| parent | Only enable the MSVC debug output sink for sessions when the --debug mode is ... (diff) | |
| download | zen-d4b7afefef2034920f1e8027af2ce292b7510592.tar.xz zen-d4b7afefef2034920f1e8027af2ce292b7510592.zip | |
NiceByteRateToBuffer could cause a divide-by-zero in some cases - fixed
Diffstat (limited to 'zencore/string.cpp')
| -rw-r--r-- | zencore/string.cpp | 12 |
1 files changed, 11 insertions, 1 deletions
diff --git a/zencore/string.cpp b/zencore/string.cpp index 6dcdc9542..49824a910 100644 --- a/zencore/string.cpp +++ b/zencore/string.cpp @@ -341,7 +341,17 @@ NiceBytesToBuffer(uint64_t Num, std::span<char> Buffer) size_t NiceByteRateToBuffer(uint64_t Num, uint64_t ElapsedMs, std::span<char> Buffer) { - size_t n = NiceNumGeneral(Num * 1000 / ElapsedMs, Buffer, kNicenumBytes); + size_t n = 0; + + if (ElapsedMs) + { + n = NiceNumGeneral(Num * 1000 / ElapsedMs, Buffer, kNicenumBytes); + } + else + { + Buffer[n++] = '0'; + Buffer[n++] = 'B'; + } Buffer[n++] = '/'; Buffer[n++] = 's'; |