diff options
author | Nicholas Clark <nick@ccl4.org> | 2012-02-24 16:13:29 +0100 |
---|---|---|
committer | Nicholas Clark <nick@ccl4.org> | 2012-02-27 11:31:48 +0100 |
commit | 8760603268ed1d1d91135ea121b222b4ee123e6e (patch) | |
tree | d3ec683528e795abd85a4002c5e3ecb4debe28f6 /parser.h | |
parent | a7c8193001a8197325b9fbb189ee567db3ca6219 (diff) | |
download | perl-8760603268ed1d1d91135ea121b222b4ee123e6e.tar.gz |
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.
Diffstat (limited to 'parser.h')
-rw-r--r-- | parser.h | 3 |
1 files changed, 2 insertions, 1 deletions
@@ -120,9 +120,10 @@ typedef struct yy_parser { # define LEX_IGNORE_UTF8_HINTS 0x00000002 # define LEX_EVALBYTES 0x00000004 # define LEX_START_COPIED 0x00000008 +# define LEX_DONT_CLOSE_RSFP 0x00000010 # define LEX_START_FLAGS \ (LEX_START_SAME_FILTER|LEX_START_COPIED \ - |LEX_IGNORE_UTF8_HINTS|LEX_EVALBYTES) + |LEX_IGNORE_UTF8_HINTS|LEX_EVALBYTES|LEX_DONT_CLOSE_RSFP) #endif /* flags for parser API */ |