summaryrefslogtreecommitdiff
path: root/lib/Travel/Status/DE/IRIS.pm
diff options
context:
space:
mode:
authorDaniel Friesel <derf@finalrewind.org>2016-04-30 09:34:48 +0200
committerDaniel Friesel <derf@finalrewind.org>2016-04-30 09:34:48 +0200
commit476b70b9f883bd89d7f6470470d1f08a9402c468 (patch)
tree6fccb60588bd2368400f26b60f16bf6798800448 /lib/Travel/Status/DE/IRIS.pm
parent694bde71f8d6abc6c0cfcc7f96ba850abf597a90 (diff)
get_station: Prevent endless while loop
Diffstat (limited to 'lib/Travel/Status/DE/IRIS.pm')
-rw-r--r--lib/Travel/Status/DE/IRIS.pm9
1 files changed, 8 insertions, 1 deletions
diff --git a/lib/Travel/Status/DE/IRIS.pm b/lib/Travel/Status/DE/IRIS.pm
index 4e3cad4..6cdf092 100644
--- a/lib/Travel/Status/DE/IRIS.pm
+++ b/lib/Travel/Status/DE/IRIS.pm
@@ -159,13 +159,15 @@ sub get_with_cache {
sub get_station {
my ( $self, %opt ) = @_;
+ my $iter_depth = 0;
my @ret;
my @queue = ( $opt{name} );
my @seen;
- while (@queue) {
+ while ( @queue and $iter_depth < 12 ) {
my $station = shift(@queue);
push( @seen, $station );
+ $iter_depth++;
my ( $raw, $err )
= $self->get_with_cache( $self->{main_cache},
@@ -212,6 +214,11 @@ sub get_station {
}
}
+ if (@queue) {
+ cluck( "Reached $iter_depth iterations when tracking station IDs. "
+ . "This is probably a bug" );
+ }
+
@ret = uniq_by { $_->{uic} } @ret;
return @ret;