diff options
author | Daniel Dragan <bulk88@hotmail.com> | 2014-05-28 08:17:25 -0400 |
---|---|---|
committer | Steve Hay <steve.m.hay@googlemail.com> | 2014-08-25 01:30:00 +0100 |
commit | 22e08dcca26db4d872c809afa16d716a23ac4309 (patch) | |
tree | 5b20f5a4d2dd2b9629c2d42d60b5a58d37bb5bb5 | |
parent | cf4e8adb31a8adc732dfa22b3ff569697d19b1da (diff) | |
download | perl-22e08dcca26db4d872c809afa16d716a23ac4309.tar.gz |
Module::CoreList::TieHashDelta stop massive recursion
On machines with very limited memory, EXISTS calling EXISTS caused a very
high number of C stack frames, magic stack swaps, and Perl call stack
frames leading to memory exhaustion. Turn the recursion into a loop. See
[perl #121974].
(cherry picked from commit 42484eedeb4abcee1d893010daa67c1a42ec6424)
-rw-r--r-- | dist/Module-CoreList/lib/Module/CoreList/TieHashDelta.pm | 4 |
1 files changed, 3 insertions, 1 deletions
diff --git a/dist/Module-CoreList/lib/Module/CoreList/TieHashDelta.pm b/dist/Module-CoreList/lib/Module/CoreList/TieHashDelta.pm index ae9947e782..a9fd40314c 100644 --- a/dist/Module-CoreList/lib/Module/CoreList/TieHashDelta.pm +++ b/dist/Module-CoreList/lib/Module/CoreList/TieHashDelta.pm @@ -32,12 +32,14 @@ sub FETCH { sub EXISTS { my ($self, $key) = @_; + restart: if (exists $self->{changed}{$key}) { return 1; } elsif (exists $self->{removed}{$key}) { return ''; } elsif (defined $self->{parent}) { - return exists $self->{parent}{$key}; + $self = tied %{$self->{parent}}; #avoid extreme magic/tie recursion + goto restart; } return ''; } |