handle the case where 0 is passed to nl_size2str
(cherry picked from commit 968ccbe97d476e3a8485b04dbaf469e8d01b8811) Signed-off-by: Thomas Graf <tgraf@suug.ch>
This commit is contained in:
parent
408a1b8f07
commit
c08aacc2e8
1 changed files with 5 additions and 0 deletions
|
@ -328,6 +328,11 @@ char *nl_size2str(const size_t size, char *buf, const size_t len)
|
|||
{
|
||||
size_t i;
|
||||
|
||||
if (size == 0) {
|
||||
snprintf(buf, len, "0B");
|
||||
return buf;
|
||||
}
|
||||
|
||||
for (i = 0; i < ARRAY_SIZE(size_units); i++) {
|
||||
if (size >= size_units[i].limit) {
|
||||
snprintf(buf, len, "%.2g%s",
|
||||
|
|
Loading…
Add table
Reference in a new issue