Re: [pcre-dev] [Bug 990] New: Crash after malloc failure

Page principale
Supprimer ce message
Auteur: Philip Hazel
Date:  
À: 990
CC: pcre-dev
Sujet: Re: [pcre-dev] [Bug 990] New: Crash after malloc failure
On Fri, 28 May 2010, eleventeen@??? wrote:

> In pcre_exec.c:
>
> #define RMATCH(ra,rb,rc,rd,re,rf,rg,rw)\
> {\
> heapframe *newframe = (pcre_stack_malloc)(sizeof(heapframe));\
> frame->Xwhere = rw; \
> newframe->Xeptr = ra;\
>
> if newframe is NULL PCRE will crash.


This is no different from the situation when PCRE uses stack for
recursion and runs out of stack.

I suppose the reason there is no check is that it will impact on
performance, and since it will very rarely bite, is it worth it?

I will do a test by inserting

if (heapframe == NULL) RRETURN(PCRE_ERROR_NOMEMORY);

and see how much it affects the performance.

I have now done that, crudely. I measured a slow down of around 2% on
one quite complicated test.

So, what does this group think? Is this extra safety check worth a
possible 2% performance hit on matches that do a lot of recursion?

Philip

--
Philip Hazel