]> granicus.if.org Git - procps-ng/commitdiff
free: use correct end sentinel
authorCraig Small <csmall@enc.com.au>
Sat, 24 Oct 2015 02:17:36 +0000 (13:17 +1100)
committerCraig Small <csmall@enc.com.au>
Sat, 24 Oct 2015 02:17:36 +0000 (13:17 +1100)
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.

free.c

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