free: use correct end sentinel

When scaling values, the last item was integer 0 but the loop checked
for character '0'.

This was reported by 付腾桂 Thanks for the report and patch.
This commit is contained in:
Craig Small 2015-10-24 13:17:36 +11:00
parent aeef4e6803
commit 97cde50b35

2
free.c
View File

@ -148,7 +148,7 @@ static const char *scale_size(unsigned long size, int flags, struct commandline_
/* human readable output */ /* human readable output */
up = nextup; up = nextup;
for (i = 1; up[0] != '0'; i++, up++) { for (i = 1; up[0] != 0; i++, up++) {
switch (i) { switch (i) {
case 1: case 1:
if (4 >= snprintf(buf, sizeof(buf), "%ld%c", (long)size * 1024, *up)) if (4 >= snprintf(buf, sizeof(buf), "%ld%c", (long)size * 1024, *up))