>> -#ifdef EGREP_PROGRAM >> -# define IF_BK(x, y) (y) >> - char *n = xmalloc (sizeof word_beg_no_bk - 1 + size + sizeof >> word_end_no_bk); > > Removing this xmalloc and using only the following one, while > correct, makes the code too fragile for my taste, because > it would then depend on word_beg_bk having the largest size.
It already does. After my patch, the corruption would be for egrep as well as grep (while before only for grep), but it's not new. > Please consider using something like > > #define MAX_BUF_SIZE \ > MAX (sizeof line_end_no_bk, > MAX (sizeof word_beg_no_bk, > ... > MAX (sizeof line_end_bk, > ... , 0))) > > and then using "2 * MAX_BUF_SIZE - 1 + size" in the xmalloc call. Queued. Paolo