From f3f5a07aa569d6fba599afcd69c04d6626c57c3f Mon Sep 17 00:00:00 2001 From: Thomas Punt Date: Mon, 7 Mar 2016 09:40:22 +0000 Subject: [PATCH] Fix DatePeriod::getEndDate() segfault --- ext/date/php_date.c | 4 ++++ ext/date/tests/bug71635.phpt | 11 +++++++++++ 2 files changed, 15 insertions(+) create mode 100644 ext/date/tests/bug71635.phpt 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 -- 2.40.0