Paul Eggert wrote: > Thanks for catching that! Here's a proposed patch that > adds a test case for this. > >>From 7b5b17d22b223994b8f439b494b25bbd3c6f85e8 Mon Sep 17 00:00:00 2001 > From: Paul Eggert <[email protected]> > Date: Sun, 11 Mar 2012 19:02:34 -0700 > Subject: [PATCH] grep: fix bug with -r --exclude-dir and no file operand > > Reported by Allan McRae in > <http://lists.gnu.org/archive/html/bug-grep/2012-03/msg00032.html>. > * src/main.c (grepdir): Don't invoke excluded_file_name on NULL. > * tests/include-exclude: Test for the bug and fix. ...
Thanks for the patch, Allan! Hi Paul, I guess you didn't notice that Allan posted the same patch that you came up with, so he is listed as the author. I've added a NEWS entry and pushed the patch below. Thanks for the test suite addition. Please add it in a separate change set. >From 12c957f786b12a4dd116f9c40a715d671d17fa16 Mon Sep 17 00:00:00 2001 From: Allan McRae <[email protected]> Date: Mon, 12 Mar 2012 09:28:01 +0100 Subject: [PATCH] grep: fix segfault with -r --exclude-dir and no file operand * src/main.c (grepdir): Don't invoke excluded_file_name on NULL. * NEWS (Bug fixes): Mention it. --- NEWS | 5 +++++ src/main.c | 2 +- 2 files changed, 6 insertions(+), 1 deletion(-) diff --git a/NEWS b/NEWS index d0a63d5..d4d70f5 100644 --- a/NEWS +++ b/NEWS @@ -2,6 +2,11 @@ GNU grep NEWS -*- outline -*- * Noteworthy changes in release ?.? (????-??-??) [?] +** Bug fixes + + grep no longer segfaults with -r --exclude-dir and no file operand. + I.e., ":|grep -r --exclude-dir=D PAT" would segfault. + * Noteworthy changes in release 2.11 (2012-03-02) [stable] diff --git a/src/main.c b/src/main.c index 2f6c761..f4f1235 100644 --- a/src/main.c +++ b/src/main.c @@ -1361,7 +1361,7 @@ grepdir (char const *dir, struct stats const *stats) struct stats const *ancestor; char *name_space; int status = 1; - if (excluded_directory_patterns + if (dir && excluded_directory_patterns && excluded_file_name (excluded_directory_patterns, dir)) return 1; -- 1.7.10.rc0.18.gf8adf
