diff --git a/src/grep.c b/src/grep.c index 889b4ec..07329cf 100644 --- a/src/grep.c +++ b/src/grep.c @@ -89,12 +89,16 @@ static int addpattern(const char *str, const size_t size) { else if (w_flag) snprintf(reg_str, rs_size + 4, "%s\\<%s%.*s%s\\>%s", (bol) ? "^" : "", (E_flag) ? "(" : "\\(", (int)size - bol - eol, ptrns[ptrns_size]->str + bol, (E_flag) ? ")" : "\\)", (eol) ? "$" : ""); + char flag = 0; if (regcomp(&ptrns[ptrns_size]->reg, reg_str, reg_flag) < 0) - goto ADDP_ERROR; + flag = 1; ptrns[ptrns_size]->reg_set = 1; if (x_flag || w_flag) free(reg_str); + + if (flag) + goto ADDP_ERROR; } ptrns_size++;