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:
Joe Damato 2013-07-07 12:12:27 -07:00 committed by Thomas Graf
parent 408a1b8f07
commit c08aacc2e8

View file

@ -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",