summaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authorNorihiro Tanaka <noritnk@kcn.ne.jp>2014-10-05 12:09:24 +0900
committerJim Meyering <meyering@fb.com>2015-04-25 12:44:01 -0700
commit599c2afbc8274d190739a623c45498b317e7f29c (patch)
treef2f1d9357eadd6b60eba0b1ff807962f50b0253d /src
parent8ee53e2a2804a7cecda91a5e249aa29e6c18f65a (diff)
downloadgrep-599c2afbc8274d190739a623c45498b317e7f29c.tar.gz
dfa: make find_pred return NULL for an invalid predicate
This could never happen when invoked via grep, but could have triggered a bug if dfa.c's find_pred function were invoked by some other program. * src/dfa.c (find_pred): Return NULL for an invalid predicate. * tests/invalid-char-class: New file to test for this. * tests/Makefile.am (TESTS): Add that new file name to the list. This addresses http://debbugs.gnu.org/18631
Diffstat (limited to 'src')
-rw-r--r--src/dfa.c5
1 files changed, 2 insertions, 3 deletions
diff --git a/src/dfa.c b/src/dfa.c
index 6c46919b..8901f69d 100644
--- a/src/dfa.c
+++ b/src/dfa.c
@@ -971,9 +971,8 @@ find_pred (const char *str)
unsigned int i;
for (i = 0; prednames[i].name; ++i)
if (STREQ (str, prednames[i].name))
- break;
-
- return &prednames[i];
+ return &prednames[i];
+ return NULL;
}
/* Multibyte character handling sub-routine for lex.