diff options
author | David Mitchell <davem@iabyn.com> | 2015-08-30 09:48:28 +0100 |
---|---|---|
committer | David Mitchell <davem@iabyn.com> | 2015-08-30 09:48:28 +0100 |
commit | 3c62f09f418b63bd79a6cbd20aaec4d992a6cc64 (patch) | |
tree | 373a193126b9ad455a658f6f78e9133a4bfbf38c /t | |
parent | 9d05662d9cd5722c93b2da7de7a50cccf9a6b9f2 (diff) | |
download | perl-3c62f09f418b63bd79a6cbd20aaec4d992a6cc64.tar.gz |
RT #125840 stop *x = $x doing bad things
If $x is a GV then *x's GP would be freed before $x's GP is assigned to
it. That would prematurely free $x, so protect it with a temporary ref
count bump.
Diffstat (limited to 't')
-rw-r--r-- | t/op/gv.t | 20 |
1 files changed, 19 insertions, 1 deletions
@@ -12,7 +12,7 @@ BEGIN { use warnings; -plan( tests => 273 ); +plan(tests => 276 ); # type coercion on assignment $foo = 'foo'; @@ -1132,6 +1132,24 @@ pass "No crash due to CvGV pointing to glob copy in the stash"; is $z, 3, 'list assignment after aliasing [perl #89646]'; } +# RT #125840: make sure *x = $x doesn't do bad things by freeing $x before +# it's assigned. + +{ + $a_125840 = 1; + $b_125840 = 2; + $a_125840 = *b_125840; + *a_125840 = $a_125840; + is($a_125840, 2, 'RT #125840: *a = $a'); + + $c_125840 = 1; + $d_125840 = 2; + *d_125840 = $d_125840 = *c_125840; + is($d_125840, 1, 'RT #125840: *d=$d=*c'); + $c_125840 = $d_125840; + is($c_125840, 1, 'RT #125840: $c=$d'); +} + __END__ Perl |