summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorHugo van der Sanden <hv@crypt.org>2002-01-08 19:17:50 +0000
committerJarkko Hietaniemi <jhi@iki.fi>2002-01-09 02:28:33 +0000
commit0e5484613ee35059bacf1903360ea858c68d8ed9 (patch)
tree6b1cca44b307f4cf132a9126bc14b227b25e0b57
parentdef8e4ea8caaa1180102a74b7613845e72bcb26c (diff)
downloadperl-0e5484613ee35059bacf1903360ea858c68d8ed9.tar.gz
(retracted by #14307)
Subject: Re: [ID 20010912.007] substr reference core dump Message-Id: <200201081917.g08JHoE15793@crypt.compulink.co.uk> p4raw-id: //depot/perl@14144
-rw-r--r--scope.c8
-rw-r--r--t/run/kill_perl.t12
2 files changed, 14 insertions, 6 deletions
diff --git a/scope.c b/scope.c
index 7c02951d26..e976f3c9fa 100644
--- a/scope.c
+++ b/scope.c
@@ -673,9 +673,7 @@ Perl_leave_scope(pTHX_ I32 base)
DEBUG_S(PerlIO_printf(Perl_debug_log,
"restore svref: %p %p:%s -> %p:%s\n",
ptr, sv, SvPEEK(sv), value, SvPEEK(value)));
- if (SvTYPE(sv) >= SVt_PVMG && SvMAGIC(sv) &&
- SvTYPE(sv) != SVt_PVGV)
- {
+ if (SvTYPE(sv) == SVt_PVMG && SvMAGIC(sv)) {
(void)SvUPGRADE(value, SvTYPE(sv));
SvMAGIC(value) = SvMAGIC(sv);
SvFLAGS(value) |= SvMAGICAL(sv);
@@ -687,9 +685,7 @@ Perl_leave_scope(pTHX_ I32 base)
* croaking that might ensue when the SvSETMAGIC() below is
* called, or to avoid two different SVs pointing at the same
* SvMAGIC()). This needs a total rethink. --GSAR */
- else if (SvTYPE(value) >= SVt_PVMG && SvMAGIC(value) &&
- SvTYPE(value) != SVt_PVGV)
- {
+ else if (SvTYPE(value) == SVt_PVMG && SvMAGIC(value)) {
SvFLAGS(value) |= (SvFLAGS(value) &
(SVp_NOK|SVp_POK)) >> PRIVSHIFT;
SvMAGICAL_off(value);
diff --git a/t/run/kill_perl.t b/t/run/kill_perl.t
index c2eb01f5ff..e36be37eb6 100644
--- a/t/run/kill_perl.t
+++ b/t/run/kill_perl.t
@@ -822,3 +822,15 @@ ok
print join '', @a, "\n";
EXPECT
123456789
+######## [ID 20010912.007] segfault or "Can't modify non-existent substring"
+$b="abcde";
+$s = \substr($b, 2, 1);
+print "before: $$s\n";
+{
+ local $k;
+ *k = $s;
+}
+print "after: $$s\n";
+EXPECT
+before: c
+after: c