]> git.ipfire.org Git - thirdparty/coreutils.git/commitdiff
maint: avoid a valgrind memory leak warning from uptime
authorAnton Ovchinnikov <revolver112@gmail.com>
Sun, 7 Jul 2013 09:29:27 +0000 (10:29 +0100)
committerPádraig Brady <P@draigBrady.com>
Sun, 7 Jul 2013 09:45:39 +0000 (10:45 +0100)
* src/uptime.c (uptime): Free utmp_buf returned from read_utmp,
to avoid a "definitely lost" warning from valgrind.

src/uptime.c

index 8e8f2ca68d41b64b4ebc40638e6633104facea3a..27b3d8d08338d6d2c49c3ca55a94271ebed881e2 100644 (file)
@@ -176,7 +176,7 @@ static void
 uptime (const char *filename, int options)
 {
   size_t n_users;
-  STRUCT_UTMP *utmp_buf;
+  STRUCT_UTMP *utmp_buf = NULL;
 
 #if HAVE_UTMPX_H || HAVE_UTMP_H
   if (read_utmp (filename, &n_users, &utmp_buf, options) != 0)
@@ -184,6 +184,8 @@ uptime (const char *filename, int options)
 #endif
 
   print_uptime (n_users, utmp_buf);
+
+  IF_LINT (free (utmp_buf));
 }
 
 void