Skip to content

Commit fcd3402

Browse files
committed
Check out-of-range long + added test
1 parent 9406baa commit fcd3402

File tree

2 files changed

+423
-2
lines changed

2 files changed

+423
-2
lines changed

ext/date/php_date.c

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2517,14 +2517,14 @@ PHPAPI bool php_date_initialize_from_ts_double(php_date_obj *dateobj, double ts)
25172517
zend_long sec;
25182518
int usec;
25192519

2520-
if (!isfinite(ts)) {
2520+
if (UNEXPECTED(isnan(ts) || !ZEND_DOUBLE_FITS_LONG(ts))) {
25212521
return 0;
25222522
}
25232523

25242524
sec = (zend_long)ts;
25252525
usec = (int)(fmod(ts, 1) * 1000000);
25262526

2527-
if (usec < 0) {
2527+
if (UNEXPECTED(usec < 0)) {
25282528
sec = sec - 1;
25292529
usec = 1000000 + usec;
25302530
}

0 commit comments

Comments
 (0)