From: Thomas Punt Date: Mon, 7 Mar 2016 09:40:22 +0000 (+0000) Subject: Fix DatePeriod::getEndDate() segfault X-Git-Tag: php-5.6.20RC1~6 X-Git-Url: https://granicus.if.org/sourcecode?a=commitdiff_plain;h=f3f5a07aa569d6fba599afcd69c04d6626c57c3f;p=php Fix DatePeriod::getEndDate() segfault --- diff --git a/ext/date/php_date.c b/ext/date/php_date.c index e06ace7f8b..4cb0ec8ff4 100644 --- a/ext/date/php_date.c +++ b/ext/date/php_date.c @@ -4536,6 +4536,10 @@ PHP_METHOD(DatePeriod, getEndDate) dpobj = (php_period_obj *)zend_object_store_get_object(getThis() TSRMLS_CC); + if (!dpobj->end) { + return; + } + php_date_instantiate(dpobj->start_ce, return_value TSRMLS_CC); dateobj = (php_date_obj *)zend_object_store_get_object(return_value TSRMLS_CC); dateobj->time = timelib_time_ctor(); diff --git a/ext/date/tests/bug71635.phpt b/ext/date/tests/bug71635.phpt new file mode 100644 index 0000000000..8c5ae25db3 --- /dev/null +++ b/ext/date/tests/bug71635.phpt @@ -0,0 +1,11 @@ +--TEST-- +Bug #71635 (segfault in DatePeriod::getEndDate() when no end date has been set) +--FILE-- +getEndDate()); +?> +--EXPECT-- +NULL \ No newline at end of file