From: Jan-Pieter Cornet <johnpc@xs4all.nl>
Date: Fri, 31 Jul 1998 12:44:57 +0000 (+0200)
Subject: de-utf-ized variation of Ilya's patch
X-Git-Url: http://git.shadowcat.co.uk/gitweb/gitweb.cgi?a=commitdiff_plain;h=19b4f81ab32719bedc893a7532029fff0bf316c9;p=p5sagit%2Fp5-mst-13.2.git

de-utf-ized variation of Ilya's patch
	Message-ID: <6ps779$hmj$1@xs1.xs4all.nl>
	Subject: Re: s/\s*$//g in majordomo causes segfault under 5.005_01

p4raw-id: //depot/maint-5.005/perl@1693
---

diff --git a/regexec.c b/regexec.c
index 47ece6a..13675cc 100644
--- a/regexec.c
+++ b/regexec.c
@@ -619,10 +619,13 @@ regexec_flags(register regexp *prog, char *stringarg, register char *strend,
 	    } else {
 		STRLEN len;
 		char *little = SvPV(prog->float_substr, len);
-		last = rninstr(s, strend, little, little + len);
+		if (len) 
+		    last = rninstr(s, strend, little, little + len);
+		else
+		    last = strend;	/* matching `$' */
 	    }
 	    if (last == NULL) goto phooey; /* Should not happen! */
-	    dontbother = strend - last - 1;
+	    dontbother = strend - last + prog->float_min_offset;
 	}
 	if (minlen && (dontbother < minlen))
 	    dontbother = minlen - 1;
@@ -638,9 +641,8 @@ regexec_flags(register regexp *prog, char *stringarg, register char *strend,
     goto phooey;
 
 got_it:
-    strend += dontbother;	/* uncheat */
     prog->subbeg = strbeg;
-    prog->subend = strend;
+    prog->subend = PL_regeol;	/* strend may have been modified */
     RX_MATCH_TAINTED_set(prog, PL_reg_flags & RF_tainted);
 
     /* make sure $`, $&, $', and $digit will work later */
@@ -652,7 +654,7 @@ got_it:
 	    }
 	}
 	else {
-	    I32 i = strend - startpos + (stringarg - strbeg);
+	    I32 i = PL_regeol - startpos + (stringarg - strbeg);
 	    s = savepvn(strbeg, i);
 	    Safefree(prog->subbase);
 	    prog->subbase = s;