summaryrefslogtreecommitdiff
path: root/cpan/autodie/t/string-eval-leak.t
blob: 329bcfa40ebc00e3029f0f97998668b3ab8a2155 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
#!/usr/bin/perl -w
use strict;
use warnings;
use Test::More tests => 2;

# Under Perl 5.10.x, a string eval can cause a copy to be taken of
# %^H, which delays stringification of our scope guard objects,
# which in turn causes autodie to leak.  These tests check to see
# if we've successfully worked around this issue.

eval {

    {
        use autodie;
        eval "1";
    }

    open(my $fh, '<', 'this_file_had_better_not_exist');
};

TODO: {
    local $TODO;

    if ( $] >= 5.010 ) {
        $TODO = "Autodie can leak near string evals in 5.10.x";
    }

    is("$@","","Autodie should not leak out of scope");
}

# However, we can plug the leak with 'no autodie'.

no autodie;

eval {
    open(my $fh, '<', 'this_file_had_better_not_exist');
};

is("$@","",'no autodie should be able to workaround this bug');