Why people would want to use this combination of options on stdin is
beyond me, but this patch at least makes this combination not segfault
and act like "grep -R" on stdin (the behaviour of which has changed in
grep-2.11...)

>From 7c64a947d09747c8414c28cbe33ab3a7c1e71cbf Mon Sep 17 00:00:00 2001
From: Allan McRae <[email protected]>
Date: Mon, 12 Mar 2012 10:54:32 +1000
Subject: [PATCH] grep: fix segfault with -R --exclude-dir on stdin

* src/main.c: ensure dir is non-NULL before calling excluded_file_name

Signed-off-by: Allan McRae <[email protected]>
---
 src/main.c |    2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

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.9.3


Reply via email to