diff options
author | Father Chrysostomos <sprout@cpan.org> | 2012-11-04 00:03:43 -0700 |
---|---|---|
committer | Father Chrysostomos <sprout@cpan.org> | 2012-11-04 22:45:33 -0800 |
commit | 10002bc1e43a1dd716ef062f4d0f900ed881a652 (patch) | |
tree | 3b3c5ef910ce05d99cb5d1010ff7efc633ba1e1d /toke.c | |
parent | 47c8e7fe4dafea45e2640fb1b39714077bda8085 (diff) | |
download | perl-10002bc1e43a1dd716ef062f4d0f900ed881a652.tar.gz |
Don’t leak pattern buffer when invalid flags croak
Normally if there is a syntax error yyerror just records it and pars-
ing continues anyway. If there are too many syntax errors, it croaks.
It just happened that if it croaked when encountering invalid flags
for quote-like operators it would leak the buffer containing the pat-
tern (and the substitution for s///).
Since those are stored in the parser struct and are set to null when-
ever something else takes ownership of the SV, these struct members
will only ever be non-null in parser_free when they have leaked. So
we can free them there. (I.e., these slots have always been refer-
ence-counted, so treat them that way.)
Diffstat (limited to 'toke.c')
-rw-r--r-- | toke.c | 2 |
1 files changed, 2 insertions, 0 deletions
@@ -784,6 +784,8 @@ Perl_parser_free(pTHX_ const yy_parser *parser) (parser->old_parser && parser->rsfp != parser->old_parser->rsfp))) PerlIO_close(parser->rsfp); SvREFCNT_dec(parser->rsfp_filters); + SvREFCNT_dec(parser->lex_stuff); + SvREFCNT_dec(parser->sublex_info.repl); Safefree(parser->lex_brackstack); Safefree(parser->lex_casestack); |