Author: jilles
Date: Sun Jul 15 15:22:13 2012
New Revision: 238488
URL: http://svn.freebsd.org/changeset/base/238488

Log:
  ps: Fix memory leak when showing start/lstart for swapped-out process.
  
  Spotted by:   scan-build (uqs)

Modified:
  head/bin/ps/print.c

Modified: head/bin/ps/print.c
==============================================================================
--- head/bin/ps/print.c Sun Jul 15 15:00:28 2012        (r238487)
+++ head/bin/ps/print.c Sun Jul 15 15:22:13 2012        (r238488)
@@ -387,12 +387,13 @@ started(KINFO *k, VARENT *ve __unused)
        size_t buflen = 100;
        char *buf;
 
+       if (!k->ki_valid)
+               return (NULL);
+
        buf = malloc(buflen);
        if (buf == NULL)
                errx(1, "malloc failed");
 
-       if (!k->ki_valid)
-               return (NULL);
        if (use_ampm < 0)
                use_ampm = (*nl_langinfo(T_FMT_AMPM) != '\0');
        then = k->ki_p->ki_start.tv_sec;
@@ -415,12 +416,13 @@ lstarted(KINFO *k, VARENT *ve __unused)
        char *buf;
        size_t buflen = 100;
 
+       if (!k->ki_valid)
+               return (NULL);
+
        buf = malloc(buflen);
        if (buf == NULL)
                errx(1, "malloc failed");
 
-       if (!k->ki_valid)
-               return (NULL);
        then = k->ki_p->ki_start.tv_sec;
        (void)strftime(buf, buflen, "%c", localtime(&then));
        return (buf);
_______________________________________________
[email protected] mailing list
http://lists.freebsd.org/mailman/listinfo/svn-src-head
To unsubscribe, send any mail to "[email protected]"

Reply via email to