Browse Source

- Fixed bug #36988 (mktime freezes on long numbers)

migration/RELEASE_1_0_0
Derick Rethans 20 years ago
parent
commit
9844b76e56
  1. 7
      ext/date/lib/timelib_structs.h
  2. 7
      ext/date/lib/tm2unixtime.c
  3. 10
      ext/date/tests/bug36988.phpt

7
ext/date/lib/timelib_structs.h

@ -183,9 +183,10 @@ typedef struct _timelib_tzdb {
#define TIMELIB_ZONETYPE_ABBR 2
#define TIMELIB_ZONETYPE_ID 3
#define SECS_PER_DAY 86400
#define DAYS_PER_YEAR 365
#define DAYS_PER_LYEAR 366
#define SECS_PER_ERA 12622780800L
#define SECS_PER_DAY 86400
#define DAYS_PER_YEAR 365
#define DAYS_PER_LYEAR 366
#define timelib_is_leap(y) ((y) % 4 == 0 && ((y) % 100 != 0 || (y) % 400 == 0))

7
ext/date/lib/tm2unixtime.c

@ -135,6 +135,13 @@ static timelib_sll do_years(timelib_sll year)
{
timelib_sll i;
timelib_sll res = 0;
timelib_sll eras;
eras = (year - 1970) / 400;
if (eras != 0) {
year = year - (eras * 400);
res += (SECS_PER_ERA * eras);
}
if (year >= 1970) {
for (i = year - 1; i >= 1970; i--) {

10
ext/date/tests/bug36988.phpt

@ -0,0 +1,10 @@
--TEST--
Bug #36988 (mktime freezes on long numbers)
--FILE--
<?php
$start = microtime(true);
$a = mktime(1, 1, 1, 1, 1, 11111111111);
echo (microtime(true) - $start) < 1 ? "smaller than one second" : "more than a second";
?>
--EXPECT--
smaller than one second
Loading…
Cancel
Save