From: Adrian M. Enache Date: Fri, 28 Mar 2003 23:53:09 +0000 (+0200) Subject: [patch] Re: [perl #21728] regexp SEGV X-Git-Url: http://git.shadowcat.co.uk/gitweb/gitweb.cgi?a=commitdiff_plain;h=4b3c1a47dc0fd4f1dba8913d1d8984fe79997756;p=p5sagit%2Fp5-mst-13.2.git [patch] Re: [perl #21728] regexp SEGV Message-ID: <20030328215309.GA6413@ratsnest.hole> (with minor tweaks) p4raw-id: //depot/perl@19431 --- diff --git a/embed.fnc b/embed.fnc index a67cd92..0d906a4 100644 --- a/embed.fnc +++ b/embed.fnc @@ -630,6 +630,7 @@ Apd |char* |savepv |const char* pv Apd |char* |savesharedpv |const char* pv Apd |char* |savepvn |const char* pv|I32 len Ap |void |savestack_grow +Ap |void |savestack_grow_cnt |I32 need Ap |void |save_aelem |AV* av|I32 idx|SV **sptr Ap |I32 |save_alloc |I32 size|I32 pad Ap |void |save_aptr |AV** aptr diff --git a/embed.h b/embed.h index 031d4bb..8f8853f 100644 --- a/embed.h +++ b/embed.h @@ -876,6 +876,7 @@ #define savesharedpv Perl_savesharedpv #define savepvn Perl_savepvn #define savestack_grow Perl_savestack_grow +#define savestack_grow_cnt Perl_savestack_grow_cnt #define save_aelem Perl_save_aelem #define save_alloc Perl_save_alloc #define save_aptr Perl_save_aptr @@ -3356,6 +3357,7 @@ #define savesharedpv(a) Perl_savesharedpv(aTHX_ a) #define savepvn(a,b) Perl_savepvn(aTHX_ a,b) #define savestack_grow() Perl_savestack_grow(aTHX) +#define savestack_grow_cnt(a) Perl_savestack_grow_cnt(aTHX_ a) #define save_aelem(a,b,c) Perl_save_aelem(aTHX_ a,b,c) #define save_alloc(a,b) Perl_save_alloc(aTHX_ a,b) #define save_aptr(a) Perl_save_aptr(aTHX_ a) diff --git a/global.sym b/global.sym index 4f77904..dca3810 100644 --- a/global.sym +++ b/global.sym @@ -374,6 +374,7 @@ Perl_savepv Perl_savesharedpv Perl_savepvn Perl_savestack_grow +Perl_savestack_grow_cnt Perl_save_aelem Perl_save_alloc Perl_save_aptr diff --git a/proto.h b/proto.h index e37aaf4..ba95647 100644 --- a/proto.h +++ b/proto.h @@ -661,6 +661,7 @@ PERL_CALLCONV char* Perl_savepv(pTHX_ const char* pv); PERL_CALLCONV char* Perl_savesharedpv(pTHX_ const char* pv); PERL_CALLCONV char* Perl_savepvn(pTHX_ const char* pv, I32 len); PERL_CALLCONV void Perl_savestack_grow(pTHX); +PERL_CALLCONV void Perl_savestack_grow_cnt(pTHX_ I32 need); PERL_CALLCONV void Perl_save_aelem(pTHX_ AV* av, I32 idx, SV **sptr); PERL_CALLCONV I32 Perl_save_alloc(pTHX_ I32 size, I32 pad); PERL_CALLCONV void Perl_save_aptr(pTHX_ AV** aptr); diff --git a/regexec.c b/regexec.c index a3c7a7d..7acee5b 100644 --- a/regexec.c +++ b/regexec.c @@ -172,7 +172,7 @@ S_regcppush(pTHX_ I32 parenfloor) Perl_croak(aTHX_ "panic: paren_elems_to_push < 0"); #define REGCP_OTHER_ELEMS 6 - SSCHECK(paren_elems_to_push + REGCP_OTHER_ELEMS); + SSGROW(paren_elems_to_push + REGCP_OTHER_ELEMS); for (p = PL_regsize; p > parenfloor; p--) { /* REGCP_PARENS_ELEMS are pushed per pairs of parentheses. */ SSPUSHINT(PL_regendp[p]); diff --git a/scope.c b/scope.c index 932390d..f738b5b 100644 --- a/scope.c +++ b/scope.c @@ -155,6 +155,13 @@ Perl_savestack_grow(pTHX) Renew(PL_savestack, PL_savestack_max, ANY); } +void +Perl_savestack_grow_cnt(pTHX_ I32 need) +{ + PL_savestack_max = PL_savestack_ix + need; + Renew(PL_savestack, PL_savestack_max, ANY); +} + #undef GROW void @@ -277,7 +284,7 @@ Perl_save_shared_pvref(pTHX_ char **str) void Perl_save_gp(pTHX_ GV *gv, I32 empty) { - SSCHECK(6); + SSGROW(6); SSPUSHIV((IV)SvLEN(gv)); SvLEN(gv) = 0; /* forget that anything was allocated here */ SSPUSHIV((IV)SvCUR(gv)); diff --git a/scope.h b/scope.h index 31528fc..e2150e8 100644 --- a/scope.h +++ b/scope.h @@ -52,7 +52,8 @@ #define SCOPE_SAVES_SIGNAL_MASK 0 #endif -#define SSCHECK(need) if (PL_savestack_ix + need > PL_savestack_max) savestack_grow() +#define SSCHECK(need) if (PL_savestack_ix + (need) > PL_savestack_max) savestack_grow() +#define SSGROW(need) if (PL_savestack_ix + (need) > PL_savestack_max) savestack_grow_cnt(need) #define SSPUSHINT(i) (PL_savestack[PL_savestack_ix++].any_i32 = (I32)(i)) #define SSPUSHLONG(i) (PL_savestack[PL_savestack_ix++].any_long = (long)(i)) #define SSPUSHBOOL(p) (PL_savestack[PL_savestack_ix++].any_bool = (p))