diff options
author | Joe Damato <ice799@gmail.com> | 2013-07-07 19:12:27 (GMT) |
---|---|---|
committer | Thomas Graf <tgraf@suug.ch> | 2013-07-18 21:10:19 (GMT) |
commit | c08aacc2e8b79d6eb644ae59bb4dc3c6287b8a6b (patch) | |
tree | c26f1593e0df75191d2fd54d9745738b554656ee /lib/utils.c | |
parent | 408a1b8f07205a82b1d142633bb37bc478c55116 (diff) | |
download | libnl-c08aacc2e8b79d6eb644ae59bb4dc3c6287b8a6b.zip libnl-c08aacc2e8b79d6eb644ae59bb4dc3c6287b8a6b.tar.gz libnl-c08aacc2e8b79d6eb644ae59bb4dc3c6287b8a6b.tar.bz2 |
handle the case where 0 is passed to nl_size2str
(cherry picked from commit 968ccbe97d476e3a8485b04dbaf469e8d01b8811)
Signed-off-by: Thomas Graf <tgraf@suug.ch>
Diffstat (limited to 'lib/utils.c')
-rw-r--r-- | lib/utils.c | 5 |
1 files changed, 5 insertions, 0 deletions
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", |