[pcre-dev] [Bug 990] Crash after malloc failure

Góra strony
Delete this message
Autor: Philip Hazel
Data:  
Dla: pcre-dev
Temat: [pcre-dev] [Bug 990] Crash after malloc failure
------- You are receiving this mail because: -------
You are on the CC list for the bug.

http://bugs.exim.org/show_bug.cgi?id=990




--- Comment #1 from Philip Hazel <ph10@???> 2010-05-29 16:56:53 ---
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


--
Configure bugmail: http://bugs.exim.org/userprefs.cgi?tab=email