[patch] Re: [perl #21728] regexp SEGV
authorAdrian M. Enache <enache@rdslink.ro>
Fri, 28 Mar 2003 23:53:09 +0000 (01:53 +0200)
committerRafael Garcia-Suarez <rgarciasuarez@gmail.com>
Mon, 5 May 2003 20:07:33 +0000 (20:07 +0000)
Message-ID: <20030328215309.GA6413@ratsnest.hole>
(with minor tweaks)

p4raw-id: //depot/perl@19431

embed.fnc
embed.h
global.sym
proto.h
regexec.c
scope.c
scope.h

index a67cd92..0d906a4 100644 (file)
--- 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 (file)
--- a/embed.h
+++ b/embed.h
 #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
 #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)
index 4f77904..dca3810 100644 (file)
@@ -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 (file)
--- 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);
index a3c7a7d..7acee5b 100644 (file)
--- 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 (file)
--- 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 (file)
--- 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))