diff options
author | Father Chrysostomos <sprout@cpan.org> | 2014-12-25 09:57:07 -0800 |
---|---|---|
committer | Father Chrysostomos <sprout@cpan.org> | 2014-12-25 10:06:50 -0800 |
commit | d8bd3d828a02f8df716063d9980b8b9af539ca42 (patch) | |
tree | 2ab8f172d8effdfc6bfe884daed9992408fb72e1 /t/op/time.t | |
parent | 19bf1007743b4337230ad3a4538df4bd94311fc4 (diff) | |
download | perl-d8bd3d828a02f8df716063d9980b8b9af539ca42.tar.gz |
[perl #123495] Stop gmtime(nan) from crashing
We were getting a time struct like this:
$12 = {
tm_sec = -2147483588,
tm_min = 2147483647,
tm_hour = -2147483624,
tm_mday = -2147483647,
tm_mon = 11,
tm_year = 69,
tm_wday = -2147483641,
tm_yday = -2147483314,
tm_isdst = 0,
tm_gmtoff = 0,
tm_zone = 0x1004f6bb6 "UTC"
}
which resulted in dayname[tmbuf.tm_wday] reading past the beginning
of the array. We should check for nan explicitly instead of falling
through to the time calculations.
Diffstat (limited to 't/op/time.t')
-rw-r--r-- | t/op/time.t | 8 |
1 files changed, 7 insertions, 1 deletions
diff --git a/t/op/time.t b/t/op/time.t index 734b838dd8..f5ce3391c0 100644 --- a/t/op/time.t +++ b/t/op/time.t @@ -6,7 +6,7 @@ BEGIN { require './test.pl'; } -plan tests => 70; +plan tests => 72; # These tests make sure, among other things, that we don't end up # burning tons of CPU for dates far in the future. @@ -238,3 +238,9 @@ SKIP: { #rt #73040 like $warning, qr/^localtime\($small_time_f\) too small/; like $warning, qr/^localtime\($small_time_f\) failed/m; } + +{ + local $^W; + is scalar gmtime("NaN"), undef, '[perl #123495] gmtime(NaN)'; + is scalar localtime("NaN"), undef, 'localtime(NaN)'; +} |