This is a live mirror of the Perl 5 development currently hosted at https://github.com/perl/perl5
The parser should always close the file handle that it opened.
authorNicholas Clark <nick@ccl4.org>
Fri, 24 Feb 2012 15:13:29 +0000 (16:13 +0100)
committerNicholas Clark <nick@ccl4.org>
Mon, 27 Feb 2012 10:31:48 +0000 (11:31 +0100)
commit8760603268ed1d1d91135ea121b222b4ee123e6e
treed3ec683528e795abd85a4002c5e3ecb4debe28f6
parenta7c8193001a8197325b9fbb189ee567db3ca6219
The parser should always close the file handle that it opened.

Previously it would leave the file handle open if it was (equal to) stdin,
on the assumption that this must have been because no script name was
supplied on the interpreter command line, so the interpreter was defaulting
to reading the script from standard input.

However, if the program has closed STDIN, then the next file handle opened
(for any reason) will have file descriptor 0. So in this situation, the
handle that require opened to read the module would be mistaken for the above
situation and left open. Effectively, this leaked a file handle.

This is now fixed, by explicitly tracking from parser creation time whether
it should keep the file handle open, and only setting this flag when
defaulting to reading the main program from standard input. This resolves
RT #37033.
MANIFEST
parser.h
perl.c
pod/perldelta.pod
t/op/require_37033.t [new file with mode: 0644]
toke.c