File perl-recontextnocurpm.diff of Package perl.6851
--- ./regcomp.c.orig 2016-08-03 15:04:42.480044213 +0000
+++ ./regcomp.c 2016-08-03 15:09:57.220043656 +0000
@@ -15456,6 +15456,8 @@ void
Perl_save_re_context(pTHX)
{
dVAR;
+ I32 nparens = -1;
+ I32 i;
struct re_save_state *state;
@@ -15483,9 +15485,20 @@ Perl_save_re_context(pTHX)
/* Save $1..$n (#18107: UTF-8 s/(\w+)/uc($1)/e); AMS 20021106. */
if (PL_curpm) {
const REGEXP * const rx = PM_GETRE(PL_curpm);
- if (rx) {
- U32 i;
- for (i = 1; i <= RX_NPARENS(rx); i++) {
+ if (rx)
+ nparens = RX_NPARENS(rx);
+ }
+
+ /* RT #124109. This is a complete hack; in the SWASHNEW case we know
+ * that PL_curpm will be null, but that utf8.pm and the modules it
+ * loads will only use $1..$3.
+ */
+ if (nparens == -1)
+ nparens = 3;
+
+ {
+ {
+ for (i = 1; i <= nparens; i++) {
char digits[TYPE_CHARS(long)];
const STRLEN len = my_snprintf(digits, sizeof(digits), "%lu", (long)i);
GV *const *const gvp