From 4629d95af99642b8ff0d5818ca57a5ddb6967b05 Mon Sep 17 00:00:00 2001 From: =?latin1?q?P=E1draig=20Brady?= Date: Thu, 2 Apr 2015 05:34:07 +0100 Subject: df: fix use of uninitialized variable reported by valgrind Conditional jump or move depends on uninitialised value(s) at 0x40380C: get_field_values (df.c:840) by 0x403E16: get_dev (df.c:994) by 0x404D65: get_all_entries (df.c:1364) by 0x405926: main (df.c:1714) * src/df.c (get_dev): Initialize the fsu.fsu_bavail_top_bit_set member, when adding placeholder entries. (main): Avoid a "definitely lost" memory leak warning from valgrind, reported by Bernhard Voelker. (cherry picked from commit bf180f8f5a53eb82054e85e26dcd1ea7c43dbdfe) --- src/df.c | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/src/df.c b/src/df.c index 3ef5d33..9d1b6bb 100644 --- a/src/df.c +++ b/src/df.c @@ -910,6 +910,7 @@ get_dev (char const *disk, char const *mount_point, char const* file, return; fstype = "-"; + fsu.fsu_bavail_top_bit_set = false; fsu.fsu_blocksize = fsu.fsu_blocks = fsu.fsu_bfree = fsu.fsu_bavail = fsu.fsu_files = fsu.fsu_ffree = UINTMAX_MAX; } @@ -931,6 +932,7 @@ get_dev (char const *disk, char const *mount_point, char const* file, if (devname && ! STREQ (devname, disk)) { fstype = "-"; + fsu.fsu_bavail_top_bit_set = false; fsu.fsu_blocksize = fsu.fsu_blocks = fsu.fsu_bfree = fsu.fsu_bavail = fsu.fsu_files = fsu.fsu_ffree = UINTMAX_MAX; } @@ -1686,6 +1688,8 @@ main (int argc, char **argv) for (i = optind; i < argc; ++i) if (argv[i]) get_entry (argv[i], &stats[i - optind]); + + IF_LINT (free (stats)); } else get_all_entries (); -- 1.7.12.1