Fix DatePeriod::getEndDate() segfault

This commit is contained in:
Thomas Punt 2016-03-07 09:40:22 +00:00 committed by Anatol Belski
parent 8cd903ea68
commit f3f5a07aa5
2 changed files with 15 additions and 0 deletions

View File

@ -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();

View File

@ -0,0 +1,11 @@
--TEST--
Bug #71635 (segfault in DatePeriod::getEndDate() when no end date has been set)
--FILE--
<?php
date_default_timezone_set('UTC');
$period = new DatePeriod(new DateTimeImmutable("now"), new DateInterval("P2Y4DT6H8M"), 2);
var_dump($period->getEndDate());
?>
--EXPECT--
NULL