Commit | Line | Data |
3357b1b1 |
1 | # Digest::MD5 2.07 and older used to trigger a core dump when |
2 | # passed an illegal file handle that failed to open. |
3 | |
ac70dec1 |
4 | print "1..3\n"; |
3357b1b1 |
5 | |
6 | use Digest::MD5 (); |
42a96e2f |
7 | use Config; |
3357b1b1 |
8 | |
9 | $md5 = Digest::MD5->new; |
10 | |
11 | eval { |
12 | use vars qw(*FOO); |
13 | $md5->addfile(*FOO); |
14 | }; |
ac70dec1 |
15 | print "not " unless $@ =~ /^Bad filehandle: FOO at/; |
3357b1b1 |
16 | print "ok 1\n"; |
17 | |
ac70dec1 |
18 | open(BAR, "no-existing-file.$$"); |
19 | eval { |
20 | $md5->addfile(*BAR); |
21 | }; |
22 | print "not " unless $@ =~ /^No filehandle passed at/; |
3357b1b1 |
23 | print "ok 2\n"; |
ac70dec1 |
24 | |
25 | open(BAR, ">no-existing-file.$$") || die; |
26 | eval { |
27 | $md5->addfile(*BAR); |
28 | }; |
42a96e2f |
29 | # Some stdio implementations don't find reading from |
30 | # write-only filehandle to be a problem. Therefore we |
31 | # cannot expect this to fail reliably with stdio. |
32 | my $stdio = !exists $Config{useperlio} || |
33 | !defined $Config{useperlio} || |
72c58aaf |
34 | (exists $ENV{PERLIO} && $ENV{PERLIO} eq 'stdio') || |
35 | defined $Config{usefaststdio}; |
42a96e2f |
36 | print "not " unless $@ =~ /^Reading from filehandle failed at/ || $stdio; |
ac70dec1 |
37 | print "ok 3\n"; |
38 | |
39 | close(BAR); |
40 | unlink("no-existing-file.$$"); |