From: Nicholas Clark <nick@ccl4.org>
Date: Wed, 30 Nov 2005 13:55:05 +0000 (+0000)
Subject: The regexp engine should check SV flags rather than SV type for
X-Git-Url: http://git.shadowcat.co.uk/gitweb/gitweb.cgi?a=commitdiff_plain;h=8f7f721921e56db1ab4fa5e3365e8f86077b2518;p=p5sagit%2Fp5-mst-13.2.git

The regexp engine should check SV flags rather than SV type for
determining if something is a reference, because under the debugger
the value returned by the swash code is SVt_PVMG.
Not doing this has the side effect of repeatedly reassigning the
same array element, which causes destructors to fire on the reassignment
which in turn causes &utf8::DESTROY to run outside of the pseudo-safety
of save_re_context, which under the debugger involves re-entering the
regexp engine, which causes corruption of the regexp engine's global
state.

p4raw-id: //depot/perl@26228
---

diff --git a/regexec.c b/regexec.c
index 6e234a2..ec13139 100644
--- a/regexec.c
+++ b/regexec.c
@@ -4668,7 +4668,7 @@ Perl_regclass_swash(pTHX_ register const regnode* node, bool doinit, SV** listsv
 	     * documentation of these array elements. */
 
 	    si = *ary;
-	    a  = SvTYPE(ary[1]) == SVt_RV   ? &ary[1] : 0;
+	    a  = SvROK(ary[1]) ? &ary[1] : 0;
 	    b  = SvTYPE(ary[2]) == SVt_PVAV ? &ary[2] : 0;
 
 	    if (a)