Skip to content

Commit b4bce59

Browse files
committed
Merge branch 'PHP-7.1' into PHP-7.2
* PHP-7.1: Fixed bug #75002 Null Pointer Dereference in timelib_time_clone
2 parents afdf751 + 1fdc518 commit b4bce59

File tree

2 files changed

+26
-0
lines changed

2 files changed

+26
-0
lines changed

ext/date/php_date.c

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1962,6 +1962,10 @@ static void date_period_it_rewind(zend_object_iterator *iter)
19621962
if (iterator->object->current) {
19631963
timelib_time_dtor(iterator->object->current);
19641964
}
1965+
if (!iterator->object->start) {
1966+
zend_throw_error(NULL, "DatePeriod has not been initialized correctly");
1967+
return;
1968+
}
19651969
iterator->object->current = timelib_time_clone(iterator->object->start);
19661970
date_period_it_invalidate_current(iter);
19671971
}

ext/date/tests/bug75002.phpt

Lines changed: 22 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,22 @@
1+
--TEST--
2+
Bug #75002 Null Pointer Dereference in timelib_time_clone
3+
--FILE--
4+
<?php
5+
6+
class aaa extends DatePeriod {
7+
public function __construct() { }
8+
}
9+
10+
$start=new DateTime( '2012-08-01' );
11+
12+
foreach (new aaa($start) as $y) {
13+
$a=$key;
14+
}
15+
16+
?>
17+
==DONE==
18+
--EXPECTF--
19+
Fatal error: Uncaught Error: DatePeriod has not been initialized correctly in %sbug75002.php:%d
20+
Stack trace:
21+
#0 {main}
22+
thrown in %sbug75002.php on line %d

0 commit comments

Comments
 (0)