From cf93a474d4757162f972857eb69a670bf2aad44d Mon Sep 17 00:00:00 2001 From: Father Chrysostomos Date: Sat, 26 Oct 2013 16:51:23 -0700 Subject: Make PL_envgv refcounted Otherwise deleting $::{ENV} will make chdir crash: $ perl -e 'delete $::{ENV}; chdir' Segmentation fault: 11 This happens because PL_envgv points to a freed SV and GvHV(PL_envgv) tries to access nonexistent fields. --- t/op/magic.t | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) (limited to 't/op/magic.t') diff --git a/t/op/magic.t b/t/op/magic.t index 10bf62c80b..0c89c3802d 100644 --- a/t/op/magic.t +++ b/t/op/magic.t @@ -5,7 +5,7 @@ BEGIN { chdir 't' if -d 't'; @INC = '../lib'; require './test.pl'; - plan (tests => 184); + plan (tests => 185); } # Test that defined() returns true for magic variables created on the fly, @@ -201,6 +201,10 @@ END is join(':',@val1), join(':',@val2); cmp_ok @val1, '>', 1; +# deleting $::{ENV} +is runperl(prog => 'delete $::{ENV}; chdir; print qq-ok\n-'), "ok\n", + 'deleting $::{ENV}'; + # regex vars 'foobarbaz' =~ /b(a)r/; is $`, 'foo'; -- cgit v1.2.1