diff options
author | Father Chrysostomos <sprout@cpan.org> | 2011-09-10 14:02:45 -0700 |
---|---|---|
committer | Father Chrysostomos <sprout@cpan.org> | 2011-09-10 15:49:10 -0700 |
commit | ca86716259195ac20de0ed1daf63e90535e872c0 (patch) | |
tree | 78349a584ab8cc88493409ae9c1c61cae13414f4 /doio.c | |
parent | 93e94d8ade64ced372985ff8643fa9a4e05d6e90 (diff) | |
download | perl-ca86716259195ac20de0ed1daf63e90535e872c0.tar.gz |
-l followed by bareword should leave the stack alone
$ ln -s /usr/bin/perl bar
$ perl -le' print "bar", -l foo'
1
The -l ate my bar.
It’s this naughty piece of code in doio.c:Perl_my_lstat_flags that is
the culprit:
if (ckWARN(WARN_IO)) {
Perl_warner(aTHX_ packWARN(WARN_IO), "Use of -l on filehandle %s",
GvENAME(cGVOP_gv));
return (PL_laststatval = -1);
}
When -l is followed by a bareward, it has no argument on the stack,
but the filetest op itself is a gvop. That snippet is from the bare-
word-handling code.
So, if warnings are off, it falls through to the argument-on-the-stack
code and pops off something does not belong to it (that belong to the
print, in the example above).
Diffstat (limited to 'doio.c')
-rw-r--r-- | doio.c | 2 |
1 files changed, 1 insertions, 1 deletions
@@ -1344,8 +1344,8 @@ Perl_my_lstat_flags(pTHX_ const U32 flags) if (ckWARN(WARN_IO)) { Perl_warner(aTHX_ packWARN(WARN_IO), "Use of -l on filehandle %s", GvENAME(cGVOP_gv)); - return (PL_laststatval = -1); } + return (PL_laststatval = -1); } else if (PL_laststype != OP_LSTAT && (PL_op->op_private & OPpFT_STACKED) && ckWARN(WARN_IO)) |