]> granicus.if.org Git - psmisc/commitdiff
prtstat: free comm field of proc_inf struct
authorJeff Smith <whydoubt@gmail.com>
Mon, 20 Mar 2017 19:41:14 +0000 (14:41 -0500)
committerJeff Smith <whydoubt@gmail.com>
Thu, 23 Mar 2017 16:49:07 +0000 (11:49 -0500)
Noticed when running tool in valgrind

src/prtstat.c

index 441a9a096adecc0247344ea8a92b645b59cac3ba..d18ea4668496b421b619a2657ba32d9ba6a982c0 100644 (file)
@@ -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);
 }