From f46b2b9f64a4930fd2450ee406ad96f1a06993be Mon Sep 17 00:00:00 2001 From: Mark Johnston Date: Sat, 5 Jan 2013 22:04:40 +0000 Subject: [PATCH] Fix a segfault when bsdgrep -i is given an empty pattern string. PR: bin/172865 Reviewed by: gabor Approved by: emaste (co-mentor) MFC after: 1 week --- usr.bin/grep/regex/tre-fastmatch.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/usr.bin/grep/regex/tre-fastmatch.c b/usr.bin/grep/regex/tre-fastmatch.c index 6f1aec6bf3b7..b7a7c91fbcfd 100644 --- a/usr.bin/grep/regex/tre-fastmatch.c +++ b/usr.bin/grep/regex/tre-fastmatch.c @@ -468,7 +468,7 @@ static int fastcmp(const fastmatch_t *fg, const void *data, fg->nosub = (cflags & REG_NOSUB); \ \ /* Cannot handle REG_ICASE with MB string */ \ - if (fg->icase && (TRE_MB_CUR_MAX > 1)) \ + if (fg->icase && (TRE_MB_CUR_MAX > 1) && n > 0) \ { \ DPRINT(("Cannot use fast matcher for MBS with REG_ICASE\n")); \ return REG_BADPAT; \