diff options
author | kevans <kevans@FreeBSD.org> | 2017-08-16 00:40:13 +0000 |
---|---|---|
committer | kevans <kevans@FreeBSD.org> | 2017-08-16 00:40:13 +0000 |
commit | 01a10a26f2dc76258dda2a0d9195de329cfb5b6f (patch) | |
tree | fe3e55f76d9e4644944971472ee551a1708a189f /usr.bin | |
parent | f54486657a1c112080e7cb3e23c6e41109ddc8b4 (diff) | |
download | FreeBSD-src-01a10a26f2dc76258dda2a0d9195de329cfb5b6f.zip FreeBSD-src-01a10a26f2dc76258dda2a0d9195de329cfb5b6f.tar.gz |
MFC r316495: bsdgrep(1): Fix errors with invalid expressions
Invalid expressions with an ultimate compiled pattern length of 0 (e.g.,
"grep -E {") were not taken into account and caused a segfault while trying
to fill in the good suffix table.
Approved by: emaste (mentor, blanket MFC)
Diffstat (limited to 'usr.bin')
-rw-r--r-- | usr.bin/grep/regex/tre-fastmatch.c | 4 |
1 files changed, 2 insertions, 2 deletions
diff --git a/usr.bin/grep/regex/tre-fastmatch.c b/usr.bin/grep/regex/tre-fastmatch.c index c6bc09d..3e5394c 100644 --- a/usr.bin/grep/regex/tre-fastmatch.c +++ b/usr.bin/grep/regex/tre-fastmatch.c @@ -337,7 +337,7 @@ static int fastcmp(const fastmatch_t *fg, const void *data, * Fills in the good suffix table for SB/MB strings. */ #define FILL_BMGS \ - if (!fg->hasdot) \ + if (fg->len > 0 && !fg->hasdot) \ { \ fg->sbmGs = malloc(fg->len * sizeof(int)); \ if (!fg->sbmGs) \ @@ -353,7 +353,7 @@ static int fastcmp(const fastmatch_t *fg, const void *data, * Fills in the good suffix table for wide strings. */ #define FILL_BMGS_WIDE \ - if (!fg->hasdot) \ + if (fg->wlen > 0 && !fg->hasdot) \ { \ fg->bmGs = malloc(fg->wlen * sizeof(int)); \ if (!fg->bmGs) \ |