bug-grep
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: [PATCH 6/9] grep: remove one #ifdef


From: Paolo Bonzini
Subject: Re: [PATCH 6/9] grep: remove one #ifdef
Date: Fri, 19 Mar 2010 15:54:52 +0100

>> -#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




reply via email to

[Prev in Thread] Current Thread [Next in Thread]