Imported Upstream version 23.0
[platform/upstream/psmisc.git] / src / prtstat.c
index 441a9a0..79f9481 100644 (file)
@@ -1,7 +1,7 @@
 /*
  * prtstat.c - Print a processes stat file
  *
- * Copyright (C) 2009-2014 Craig Small
+ * Copyright (C) 2009-2017 Craig Small
  * Based upon a shell script pstat by martin f. krafft <madduck@madduck.net>
  *
  * This program is free software; you can redistribute it and/or modify
@@ -63,7 +63,7 @@ static void usage(const char *errormsg)
 static void print_version(void)
 {
   fprintf(stderr, _("prtstat (PSmisc) %s\n"), VERSION);
-  fprintf(stderr, _( "Copyright (C) 2009 Craig Small\n\n"));
+  fprintf(stderr, _( "Copyright (C) 2009-2017 Craig Small\n\n"));
   fprintf(stderr, _(
                "PSmisc comes with ABSOLUTELY NO WARRANTY.\n"
                "This is free software, and you are welcome to redistribute it under\n"
@@ -243,6 +243,7 @@ static void print_stat(const int pid, const opt_type options)
       fprintf(stderr, _("Unable to allocate memory for proc_info\n"));
       return;
   }
+  pr->comm = NULL;
   if (sscanf(bptr,
          "%m[^)]) "
          "%c "
@@ -280,6 +281,7 @@ static void print_stat(const int pid, const opt_type options)
         print_formated_stat(pid, pr);
          } else 
              fprintf(stderr, _("Unable to scan stat file"));
+  free(pr->comm);
   free(pr);
 }