This is a live mirror of the Perl 5 development currently hosted at https://github.com/perl/perl5
Trap Time::Local infinite loop
[perl5.git] / lib / Time / Local.pm
index d2d70da..3aa0cfc 100644 (file)
@@ -107,7 +107,9 @@ sub cheat {
     @g = gmtime($guess);
     $year += $YearFix if $year < $epoch;
     $lastguess = "";
+    $counter = 0;
     while ($diff = $year - $g[5]) {
+       croak "Couldn't handle date (".join(", ",@_).")" if ++$counter > 255;
        $guess += $diff * (363 * $DAY);
        @g = gmtime($guess);
        if (($thisguess = "@g") eq $lastguess){
@@ -116,6 +118,7 @@ sub cheat {
        $lastguess = $thisguess;
     }
     while ($diff = $month - $g[4]) {
+       croak "Couldn't handle date (".join(", ",@_).")" if ++$counter > 255;
        $guess += $diff * (27 * $DAY);
        @g = gmtime($guess);
        if (($thisguess = "@g") eq $lastguess){