From: Joe Damato Date: Sun, 7 Jul 2013 19:12:27 +0000 (-0700) Subject: handle the case where 0 is passed to nl_size2str X-Git-Tag: libnl3_2_23rc1~35 X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=c08aacc2e8b79d6eb644ae59bb4dc3c6287b8a6b;p=thirdparty%2Flibnl.git handle the case where 0 is passed to nl_size2str (cherry picked from commit 968ccbe97d476e3a8485b04dbaf469e8d01b8811) Signed-off-by: Thomas Graf --- 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",