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 /t | |
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 't')
-rw-r--r-- | t/op/svleak.t | 4 |
1 files changed, 3 insertions, 1 deletions
diff --git a/t/op/svleak.t b/t/op/svleak.t index ee646d7c8b..dfb1886091 100644 --- a/t/op/svleak.t +++ b/t/op/svleak.t @@ -15,7 +15,7 @@ BEGIN { use Config; -plan tests => 50; +plan tests => 52; # run some code N times. If the number of SVs at the end of loop N is # greater than (N-1)*delta at the end of loop 1, we've got a leak @@ -195,6 +195,8 @@ eleak(2, 0, 'tr/9-0//'); eleak(2, 0, 'tr/a-z-0//'); eleak(2, 0, 'no warnings; nonexistent_function 33838', 'bareword followed by number'); +eleak(2, 0, '//dd;'x20, '"too many errors" when parsing m// flags'); +eleak(2, 0, 's///dd;'x20, '"too many errors" when parsing s/// flags'); # [perl #114764] Attributes leak scalars leak(2, 0, sub { eval 'my $x : shared' }, 'my $x :shared used to leak'); |