From: Gurusamy Sarathy Date: Sun, 25 Apr 1999 22:58:27 +0000 (+0000) Subject: fix buggy reference count on refs to SVs with autoviv magic X-Git-Url: http://git.shadowcat.co.uk/gitweb/gitweb.cgi?a=commitdiff_plain;h=0dd88869d3c6272dc66f202c5be0f40bfb94fccd;p=p5sagit%2Fp5-mst-13.2.git fix buggy reference count on refs to SVs with autoviv magic (resulted in C and Data::Dumper accessing free()d memory) p4raw-id: //depot/perl@3270 --- diff --git a/pp.c b/pp.c index 8c48574..e6a2e11 100644 --- a/pp.c +++ b/pp.c @@ -512,6 +512,8 @@ refto(SV *sv) vivify_defelem(sv); if (!(sv = LvTARG(sv))) sv = &PL_sv_undef; + else + SvREFCNT_inc(sv); } else if (SvPADTMP(sv)) sv = newSVsv(sv); diff --git a/t/op/ref.t b/t/op/ref.t index 1d70f9f..618cfcc 100755 --- a/t/op/ref.t +++ b/t/op/ref.t @@ -1,6 +1,6 @@ #!./perl -print "1..55\n"; +print "1..56\n"; # Test glob operations. @@ -271,14 +271,22 @@ print $$_,"\n"; print "# good, didn't recurse\n"; } +# test if refgen behaves with autoviv magic + +{ + my @a; + $a[1] = "ok 53\n"; + print ${\$_} for @a; +} + # test global destruction package FINALE; { - $ref3 = bless ["ok 55\n"]; # package destruction - my $ref2 = bless ["ok 54\n"]; # lexical destruction - local $ref1 = bless ["ok 53\n"]; # dynamic destruction + $ref3 = bless ["ok 56\n"]; # package destruction + my $ref2 = bless ["ok 55\n"]; # lexical destruction + local $ref1 = bless ["ok 54\n"]; # dynamic destruction 1; # flush any temp values on stack }