]> granicus.if.org Git - procps-ng/commitdiff
pgrep: core dropped nearly always
authorSami Kerola <kerolasa@iki.fi>
Sun, 20 Nov 2011 21:16:35 +0000 (22:16 +0100)
committerSami Kerola <kerolasa@iki.fi>
Sun, 20 Nov 2011 21:16:35 +0000 (22:16 +0100)
The do_regcomp() tries to free command line argument.

Signed-off-by: Sami Kerola <kerolasa@iki.fi>
pgrep.c

diff --git a/pgrep.c b/pgrep.c
index 5492fa7231ea4f9b48d643f91d896d70f2a66c3c..1627cef527262477c7f7d4f5ab8ad037be57778c 100644 (file)
--- a/pgrep.c
+++ b/pgrep.c
@@ -409,7 +409,8 @@ static regex_t * do_regcomp (void)
                }
 
                re_err = regcomp (preg, re, REG_EXTENDED | REG_NOSUB | opt_case);
-               free(re);
+               if (opt_exact)
+                       free(re);
                if (re_err) {
                        regerror (re_err, preg, errbuf, sizeof(errbuf));
                        fputs(errbuf,stderr);