com php-src: Fixed bug #55397: Comparsion of incomplete DateTime causes SIGSEGV.: ext/date/php_date.c ext/date/tests/bug553 97.phpt
| From: | Derick Rethans | Date: | Sun, 06 Jan 2013 13:39:34 +0000 |
| Subject: | com php-src: Fixed bug #55397: Comparsion of incomplete DateTime causes SIGSEGV.: ext/date/php_date.c ext/date/tests/bug553 97.phpt | ||
| Groups: | php.cvs | ||
| Request: | Send a blank email to php-cvs+get-70871@lists.php.net to get a copy of this message | ||
Commit: ff9c1b12ff9c9533367d0d6200eb39189ad0124c
Author: Derick Rethans <github@derickrethans.nl> Sun, 6 Jan 2013 13:38:22 +0000
Parents: bc11e6fdbbafbd0969fc47fa087c2245317cd31f
Branches: PHP-5.3
Link: http://git.php.net/?p=php-src.git;a=commitdiff;h=ff9c1b12ff9c9533367d0d6200eb39189ad0124c
Log:
Fixed bug #55397: Comparsion of incomplete DateTime causes SIGSEGV.
Bugs:
https://bugs.php.net/55397
Changed paths:
M ext/date/php_date.c
A ext/date/tests/bug55397.phpt
Diff:
diff --git a/ext/date/php_date.c b/ext/date/php_date.c
index 2b4b4b5..2e616b1 100644
--- a/ext/date/php_date.c
+++ b/ext/date/php_date.c
@@ -2079,7 +2079,11 @@ static int date_object_compare_date(zval *d1, zval *d2 TSRMLS_DC)
instanceof_function(Z_OBJCE_P(d2), date_ce_date TSRMLS_CC)) {
php_date_obj *o1 = zend_object_store_get_object(d1 TSRMLS_CC);
php_date_obj *o2 = zend_object_store_get_object(d2 TSRMLS_CC);
-
+
+ if (!o1->time || !o2->time) {
+ php_error_docref(NULL TSRMLS_CC, E_WARNING, "Trying to compare an incomplete DateTime
object");
+ return 1;
+ }
if (!o1->time->sse_uptodate) {
timelib_update_ts(o1->time, o1->time->tz_info);
}
diff --git a/ext/date/tests/bug55397..phpt b/ext/date/tests/bug55397.phpt
new file mode 100644
index 0000000...efc09b5
--- /dev/null
+++ b/ext/date/tests/bug55397.phpt
@@ -0,0 +1,11 @@
+--TEST--
+Bug #55397 (comparsion of incomplete DateTime causes SIGSEGV)
+--INI--
+--FILE--
+<?php
+date_default_timezone_set('Europe/Prague');
+var_dump(unserialize('O:8:"DateTime":0:{}') == new DateTime);
+?>
+--EXPECTF--
+Warning: %s: Trying to compare an incomplete DateTime object in %s on line %d
+bool(false)