Re: [pcre-dev] doubtful code in compile_branch()

Page principale
Supprimer ce message
Auteur: Philip Hazel
Date:  
À: Issaana
CC: Pcre-dev
Sujet: Re: [pcre-dev] doubtful code in compile_branch()
On Mon, 5 May 2008, Issaana@??? wrote:

> I found the doubtful code in compile_branch().
>
>     if (code > cd->start_workspace + COMPILE_WORK_SIZE) /* Check for 
> overrun */

>
> Is it too late when an overrun happened? Because the address for return
> from the function in stack may be destroyed.
>
> Therefore I think that a code such as follow is better.
>
>     if (code > cd-start_workspace + COMPILE_WORK_SIZE - X_SIZE) /* Check 
> for overrun */

>
> X_SIZE is the max number of bytes that is used in one loop. Perhaps it
> is about 80-90 bytes when a pattern is [\H] in UTF8 mode.


Unfortunately, there is no upper limit to the number of bytes that can
be used in the loop. A [] class with a lot of UTF-8 characters might use
quite a lot of bytes.

The check for overrun is very much a paranoia check - it *should* never
actually be activated.

[Incidentally, does anybody know why C arranges its stack so that
overruns hit the return data, rather than putting the return data at the
bottom? This is something that I've wondered about for years.]

Philip

--
Philip Hazel