From c08aacc2e8b79d6eb644ae59bb4dc3c6287b8a6b Mon Sep 17 00:00:00 2001 From: Joe Damato Date: Sun, 7 Jul 2013 12:12:27 -0700 Subject: [PATCH] handle the case where 0 is passed to nl_size2str (cherry picked from commit 968ccbe97d476e3a8485b04dbaf469e8d01b8811) Signed-off-by: Thomas Graf --- lib/utils.c | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/lib/utils.c b/lib/utils.c index 4457b1f..e491177 100644 --- a/lib/utils.c +++ b/lib/utils.c @@ -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", -- 2.40.0