Skip to content

Commit

Permalink
[perl #125115] don't create file GLOB(...) when dupping a closed handle
Browse files Browse the repository at this point in the history
  • Loading branch information
tonycoz committed Jun 3, 2015
1 parent ef5cf9f commit 0c9375a
Show file tree
Hide file tree
Showing 2 changed files with 14 additions and 3 deletions.
7 changes: 5 additions & 2 deletions doio.c
Expand Up @@ -438,8 +438,11 @@ Perl_do_open6(pTHX_ GV *gv, const char *oname, STRLEN len,
else if (IoTYPE(thatio) == IoTYPE_SOCKET)
IoTYPE(io) = IoTYPE_SOCKET;
}
else
wanted_fd = -1;
else {
SETERRNO(EBADF, RMS_IFI);
fp = NULL;
goto say_false;
}
}
if (!num_svs)
type = NULL;
Expand Down
10 changes: 9 additions & 1 deletion t/io/open.t
Expand Up @@ -10,7 +10,7 @@ $| = 1;
use warnings;
use Config;

plan tests => 153;
plan tests => 156;

my $Perl = which_perl();

Expand Down Expand Up @@ -476,6 +476,14 @@ pass("no crash when open autovivifies glob in freed package");
is((stat $temp)[9], $final_mtime, "nothing changes its mtime");
}

# [perl #125115] Dup to closed filehandle creates file named GLOB(0x...)
{
ok(open(my $fh, "<", "TEST"), "open a handle");
ok(close $fh, "and close it again");
ok(!open(my $fh2, ">&", $fh), "should fail to dup the closed handle");
# clean up if we failed
unlink "$fh";
}

package OverloadTest;
use overload '""' => sub { ${$_[0]} };

0 comments on commit 0c9375a

Please sign in to comment.