From: Brandon L Black Date: Thu, 9 Nov 2006 22:33:14 +0000 (+0000) Subject: s/1/2/ X-Git-Tag: 0.06~10 X-Git-Url: http://git.shadowcat.co.uk/gitweb/gitweb.cgi?a=commitdiff_plain;h=e742c620a00d483d8284f0021a69d9126894c482;p=gitmo%2FAlgorithm-C3.git s/1/2/ --- diff --git a/lib/Algorithm/C3.pm b/lib/Algorithm/C3.pm index be88dc5..009bc10 100644 --- a/lib/Algorithm/C3.pm +++ b/lib/Algorithm/C3.pm @@ -24,10 +24,12 @@ sub merge { my $current_parents = [ $root->$parent_fetcher ]; my $recurse_mergeout = []; my $i = 0; + my %seen; while(1) { if($i < @$current_parents) { my $new_root = $current_parents->[$i++]; + die "Infinite loop detected" if $seen{$new_root}++; unless ($pfetcher_is_coderef or $new_root->can($parent_fetcher)) { confess "Could not find method $parent_fetcher in $new_root"; diff --git a/t/011_infinite_loop.t b/t/011_infinite_loop.t index 24f4e76..05af588 100644 --- a/t/011_infinite_loop.t +++ b/t/011_infinite_loop.t @@ -3,7 +3,7 @@ use strict; use warnings; -use Test::More tests => 1; +use Test::More tests => 2; BEGIN { use_ok('Algorithm::C3');