]> granicus.if.org Git - procps-ng/commitdiff
For free -b make the variable a long long
authorCraig Small <csmall@enc.com.au>
Wed, 4 Jan 2012 22:37:58 +0000 (09:37 +1100)
committerCraig Small <csmall@enc.com.au>
Wed, 4 Jan 2012 22:46:39 +0000 (09:46 +1100)
Bug-Debian: http://bugs.debian.org/654368

On systems with very large amonut of RAM when they use the -b or --bytes
option on free you get overflow and free shows a negative amount of
memory, which is obviously wrong.

free.c

diff --git a/free.c b/free.c
index 1aaa5ecbfea5544c91faa344169f9694a5bf3fe8..54825ab002378708eb1e0d8e46219d1ce0d4a94b 100644 (file)
--- a/free.c
+++ b/free.c
@@ -106,7 +106,7 @@ static const char *scale_size(unsigned long size, int flags, struct commandline_
        if (!(flags & FREE_HUMANREADABLE)) {
                if (args.exponent == 1) {
                        /* in bytes, which can not be in SI */
-                       snprintf(buf, sizeof(buf), "%ld", (long int)(size * 1024));
+                       snprintf(buf, sizeof(buf), "%lld", (long long int)(size * 1024));
                        return buf;
                }
                if (args.exponent == 2) {