From: Jeff Smith Date: Mon, 20 Mar 2017 19:41:14 +0000 (-0500) Subject: prtstat: free comm field of proc_inf struct X-Git-Tag: v23.0~15^2^2~2 X-Git-Url: https://granicus.if.org/sourcecode?a=commitdiff_plain;h=230c42f4ad797cd6684924d585c5b87180eb6a27;p=psmisc prtstat: free comm field of proc_inf struct Noticed when running tool in valgrind --- diff --git a/src/prtstat.c b/src/prtstat.c index 441a9a0..d18ea46 100644 --- a/src/prtstat.c +++ b/src/prtstat.c @@ -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); }