Skip to content

Commit 2adf58c

Browse files
committed
- Fixed bug #54283 (new DatePeriod(NULL) causes crash)
1 parent 63673a5 commit 2adf58c

File tree

2 files changed

+15
-1
lines changed

2 files changed

+15
-1
lines changed

ext/date/php_date.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3762,7 +3762,7 @@ PHP_METHOD(DatePeriod, __construct)
37623762
dpobj = zend_object_store_get_object(getThis() TSRMLS_CC);
37633763
dpobj->current = NULL;
37643764

3765-
if (isostr_len) {
3765+
if (isostr) {
37663766
date_period_initialize(&(dpobj->start), &(dpobj->end), &(dpobj->interval), &recurrences, isostr, isostr_len TSRMLS_CC);
37673767
if (dpobj->start == NULL) {
37683768
php_error_docref(NULL TSRMLS_CC, E_WARNING, "The ISO interval '%s' did not contain a start date.", isostr);

ext/date/tests/bug54283.phpt

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,14 @@
1+
--TEST--
2+
Bug #54283 (new DatePeriod(NULL) causes crash)
3+
--FILE--
4+
<?php
5+
6+
try {
7+
var_dump(new DatePeriod(NULL));
8+
} catch (Exception $e) {
9+
var_dump($e->getMessage());
10+
}
11+
12+
?>
13+
--EXPECTF--
14+
string(51) "DatePeriod::__construct(): Unknown or bad format ()"

0 commit comments

Comments
 (0)