mirror of
https://github.com/php/php-src.git
synced 2024-12-01 13:54:10 +08:00
Fix DatePeriod::getEndDate() segfault
This commit is contained in:
parent
8cd903ea68
commit
f3f5a07aa5
@ -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();
|
||||
|
11
ext/date/tests/bug71635.phpt
Normal file
11
ext/date/tests/bug71635.phpt
Normal 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
|
Loading…
Reference in New Issue
Block a user