summaryrefslogtreecommitdiff
path: root/regexec.c
diff options
context:
space:
mode:
authorHugo van der Sanden <hv@crypt.org>2000-10-23 01:47:22 +0100
committerJarkko Hietaniemi <jhi@iki.fi>2000-10-23 03:43:12 +0000
commita1933d9520524187cd6ffbd1408c92d37eba7fe2 (patch)
tree6b716d9efb659c4dce5738c23249b48ce99544f2 /regexec.c
parente35b8f9e3de730f96348d8d0ecac4d41eb9cb37e (diff)
downloadperl-a1933d9520524187cd6ffbd1408c92d37eba7fe2.tar.gz
Re: [ID 20001021.005] SEGV with regex match
Message-Id: <200010222347.AAA09697@crypt.compulink.co.uk> p4raw-id: //depot/perl@7407
Diffstat (limited to 'regexec.c')
-rw-r--r--regexec.c9
1 files changed, 5 insertions, 4 deletions
diff --git a/regexec.c b/regexec.c
index d3f2065cbc..6e046f3abc 100644
--- a/regexec.c
+++ b/regexec.c
@@ -325,6 +325,7 @@ Perl_re_intuit_start(pTHX_ regexp *prog, SV *sv, char *strpos,
register I32 end_shift;
register char *s;
register SV *check;
+ char *strbeg;
char *t;
I32 ml_anch;
char *tmp;
@@ -351,6 +352,7 @@ Perl_re_intuit_start(pTHX_ regexp *prog, SV *sv, char *strpos,
DEBUG_r(PerlIO_printf(Perl_debug_log, "String too short...\n"));
goto fail;
}
+ strbeg = (sv && SvPOK(sv)) ? strend - SvCUR(sv) : strpos;
check = prog->check_substr;
if (prog->reganch & ROPT_ANCH) { /* Match at beg-of-str or after \n */
ml_anch = !( (prog->reganch & ROPT_ANCH_SINGLE)
@@ -361,7 +363,7 @@ Perl_re_intuit_start(pTHX_ regexp *prog, SV *sv, char *strpos,
if ( !(prog->reganch & ROPT_ANCH_GPOS) /* Checked by the caller */
/* SvCUR is not set on references: SvRV and SvPVX overlap */
&& sv && !SvROK(sv)
- && (strpos + SvCUR(sv) != strend)) {
+ && (strpos != strbeg)) {
DEBUG_r(PerlIO_printf(Perl_debug_log, "Not at start...\n"));
goto fail;
}
@@ -428,7 +430,6 @@ Perl_re_intuit_start(pTHX_ regexp *prog, SV *sv, char *strpos,
/* Find a possible match in the region s..strend by looking for
the "check" substring in the region corrected by start/end_shift. */
if (flags & REXEC_SCREAM) {
- char *strbeg = SvPVX(sv); /* XXXX Assume PV_force() on SCREAM! */
I32 p = -1; /* Internal iterator of scream. */
I32 *pp = data ? data->scream_pos : &p;
@@ -670,7 +671,7 @@ Perl_re_intuit_start(pTHX_ regexp *prog, SV *sv, char *strpos,
/* Even in this situation we may use MBOL flag if strpos is offset
wrt the start of the string. */
if (ml_anch && sv && !SvROK(sv) /* See prev comment on SvROK */
- && (strpos + SvCUR(sv) != strend) && strpos[-1] != '\n'
+ && (strpos != strbeg) && strpos[-1] != '\n'
/* May be due to an implicit anchor of m{.*foo} */
&& !(prog->reganch & ROPT_IMPLICIT))
{
@@ -721,7 +722,7 @@ Perl_re_intuit_start(pTHX_ regexp *prog, SV *sv, char *strpos,
? s + (prog->minlen? cl_l : 0)
: (prog->float_substr ? check_at - start_shift + cl_l
: strend) ;
- char *startpos = sv && SvPOK(sv) ? strend - SvCUR(sv) : s;
+ char *startpos = strbeg;
t = s;
if (prog->reganch & ROPT_UTF8) {