Skip to content

Commit ff9c1b1

Browse files
committed
Fixed bug #55397: Comparsion of incomplete DateTime causes SIGSEGV.
1 parent bc11e6f commit ff9c1b1

File tree

2 files changed

+16
-1
lines changed

2 files changed

+16
-1
lines changed

ext/date/php_date.c

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2079,7 +2079,11 @@ static int date_object_compare_date(zval *d1, zval *d2 TSRMLS_DC)
20792079
instanceof_function(Z_OBJCE_P(d2), date_ce_date TSRMLS_CC)) {
20802080
php_date_obj *o1 = zend_object_store_get_object(d1 TSRMLS_CC);
20812081
php_date_obj *o2 = zend_object_store_get_object(d2 TSRMLS_CC);
2082-
2082+
2083+
if (!o1->time || !o2->time) {
2084+
php_error_docref(NULL TSRMLS_CC, E_WARNING, "Trying to compare an incomplete DateTime object");
2085+
return 1;
2086+
}
20832087
if (!o1->time->sse_uptodate) {
20842088
timelib_update_ts(o1->time, o1->time->tz_info);
20852089
}

ext/date/tests/bug55397.phpt

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,11 @@
1+
--TEST--
2+
Bug #55397 (comparsion of incomplete DateTime causes SIGSEGV)
3+
--INI--
4+
--FILE--
5+
<?php
6+
date_default_timezone_set('Europe/Prague');
7+
var_dump(unserialize('O:8:"DateTime":0:{}') == new DateTime);
8+
?>
9+
--EXPECTF--
10+
Warning: %s: Trying to compare an incomplete DateTime object in %s on line %d
11+
bool(false)

0 commit comments

Comments
 (0)