diff options
Diffstat (limited to 't')
-rw-r--r-- | t/comp/hints.t | 20 | ||||
-rwxr-xr-x | t/op/magic.t | 2 | ||||
-rwxr-xr-x | t/op/ref.t | 12 | ||||
-rwxr-xr-x | t/op/substr.t | 13 |
4 files changed, 43 insertions, 4 deletions
diff --git a/t/comp/hints.t b/t/comp/hints.t index 117096860f..f00bb6a893 100644 --- a/t/comp/hints.t +++ b/t/comp/hints.t @@ -2,7 +2,13 @@ # Tests the scoping of $^H and %^H -BEGIN { print "1..14\n"; } +BEGIN { + chdir 't' if -d 't'; + @INC = qw(. ../lib); +} + + +BEGIN { print "1..15\n"; } BEGIN { print "not " if exists $^H{foo}; print "ok 1 - \$^H{foo} doesn't exist initially\n"; @@ -55,3 +61,15 @@ BEGIN { print "not " if $^H & 0x00020000; print "ok 8 - \$^H doesn't contain HINT_LOCALIZE_HH while finishing compilation\n"; } + +require 'test.pl'; + +# bug #27040: hints hash was being double-freed +my $result = runperl( + prog => '$^H |= 0x20000; eval q{BEGIN { $^H |= 0x20000 }}', + stderr => 1 +); +print "not " if length $result; +print "ok 15 - double-freeing hints hash\n"; +print "# got: $result\n" if length $result; + diff --git a/t/op/magic.t b/t/op/magic.t index dda07dfbc9..1c02b5bbad 100755 --- a/t/op/magic.t +++ b/t/op/magic.t @@ -349,7 +349,7 @@ else { } if ($Is_miniperl) { - skip ("miniperl can't rely on loading %Errno"); + skip ("miniperl can't rely on loading %Errno") for 1..2; } else { no warnings 'void'; diff --git a/t/op/ref.t b/t/op/ref.t index 3bb280c1ea..597e03698c 100755 --- a/t/op/ref.t +++ b/t/op/ref.t @@ -5,7 +5,7 @@ BEGIN { @INC = qw(. ../lib); } -print "1..68\n"; +print "1..69\n"; require 'test.pl'; @@ -357,6 +357,16 @@ runperl(prog => 'sub f { my $x = shift; *z = $x; } f({}); f();'); if ($? != 0) { print "not " }; print "ok ",++$test," - coredump on typeglob = (SvRV && !SvROK)\n"; +# bug #27268: freeing self-referential typeglobs could trigger +# "Attempt to free unreferenced scalar" warnings + +$result = runperl( + prog => 'use Symbol;my $x=bless \gensym,"t"; print;*$$x=$x', + stderr => 1 +); +print "not " if length $result; +print "ok ",++$test," - freeing self-referential typeglob\n"; +print "# got: $result\n" if length $result; # test global destruction diff --git a/t/op/substr.t b/t/op/substr.t index dfb483aee5..4df6426388 100755 --- a/t/op/substr.t +++ b/t/op/substr.t @@ -1,6 +1,6 @@ #!./perl -print "1..177\n"; +print "1..179\n"; #P = start of string Q = start of substr R = end of substr S = end of string @@ -609,3 +609,14 @@ ok 174, $x eq "\x{100}\x{200}\xFFb"; my $y = substr $x, 4; ok 177, substr($x, 7, 1) eq "7"; } + +# [perl #24200] string corruption with lvalue sub + +{ + my $foo = "a"; + sub bar: lvalue { substr $foo, 0 } + bar = "XXX"; + ok 178, bar eq 'XXX'; + $foo = '123456789'; + ok 179, bar eq '123456789'; +} |