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. Submitted by: Kyle Evans <kevans91 at ksu.edu> Reviewed by: me Differential Revision: https://reviews.freebsd.org/D10113
This commit is contained in:
parent
fd70242dbc
commit
f48d142551
@ -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) \
|
||||
|
Loading…
x
Reference in New Issue
Block a user