Index: usr.bin/grep/regex/tre-fastmatch.c =================================================================== --- usr.bin/grep/regex/tre-fastmatch.c +++ usr.bin/grep/regex/tre-fastmatch.c @@ -338,7 +338,7 @@ * Fills in the good suffix table for SB/MB strings. */ #define FILL_BMGS \ - if (!fg->hasdot) \ + if (fg->len > 0 && !fg->hasdot) \ { \ fg->sbmGs = xmalloc(fg->len * sizeof(int)); \ if (!fg->sbmGs) \ @@ -354,7 +354,7 @@ * Fills in the good suffix table for wide strings. */ #define FILL_BMGS_WIDE \ - if (!fg->hasdot) \ + if (fg->wlen > 0 && !fg->hasdot) \ { \ fg->bmGs = xmalloc(fg->wlen * sizeof(int)); \ if (!fg->bmGs) \