summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorAdrian M. Enache <enache@rdslink.ro>2003-03-29 01:53:09 +0200
committerRafael Garcia-Suarez <rgarciasuarez@gmail.com>2003-05-05 20:07:33 +0000
commit4b3c1a47dc0fd4f1dba8913d1d8984fe79997756 (patch)
treed9997bad58e169c9c44a18aa34a1eb1bd6a214c0
parent048912995c485d977c9d43b63b517de870c722d5 (diff)
downloadperl-4b3c1a47dc0fd4f1dba8913d1d8984fe79997756.tar.gz
[patch] Re: [perl #21728] regexp SEGV
Message-ID: <20030328215309.GA6413@ratsnest.hole> (with minor tweaks) p4raw-id: //depot/perl@19431
-rw-r--r--embed.fnc1
-rw-r--r--embed.h2
-rw-r--r--global.sym1
-rw-r--r--proto.h1
-rw-r--r--regexec.c2
-rw-r--r--scope.c9
-rw-r--r--scope.h3
7 files changed, 16 insertions, 3 deletions
diff --git a/embed.fnc b/embed.fnc
index a67cd92b50..0d906a4cf8 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 031d4bbfb5..8f8853f79a 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 4f779049ab..dca38103c7 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 e37aaf49fe..ba95647b07 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 a3c7a7d668..7acee5b3e6 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 932390de0f..f738b5b68c 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 31528fcb09..e2150e87c0 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))