Skip to content

Commit

Permalink
Fixed bug #75002 Null Pointer Dereference in timelib_time_clone
Browse files Browse the repository at this point in the history
  • Loading branch information
Derick Rethans authored and weltling committed Aug 2, 2017
1 parent 666cb6c commit b112d09
Show file tree
Hide file tree
Showing 2 changed files with 26 additions and 0 deletions.
4 changes: 4 additions & 0 deletions ext/date/php_date.c
Original file line number Diff line number Diff line change
Expand Up @@ -1932,6 +1932,10 @@ static void date_period_it_rewind(zend_object_iterator *iter)
if (iterator->object->current) {
timelib_time_dtor(iterator->object->current);
}
if (!iterator->object->start) {
zend_throw_error(NULL, "DatePeriod has not been initialized correctly");
return;
}
iterator->object->current = timelib_time_clone(iterator->object->start);
date_period_it_invalidate_current(iter);
}
Expand Down
22 changes: 22 additions & 0 deletions ext/date/tests/bug75002.phpt
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
--TEST--
Bug #75002 Null Pointer Dereference in timelib_time_clone
--FILE--
<?php

class aaa extends DatePeriod {
public function __construct() { }
}

$start=new DateTime( '2012-08-01' );

foreach (new aaa($start) as $y) {
$a=$key;
}

?>
==DONE==
--EXPECTF--
Fatal error: Uncaught Error: DatePeriod has not been initialized correctly in %sbug75002.php:%d
Stack trace:
#0 {main}
thrown in %sbug75002.php on line %d

0 comments on commit b112d09

Please sign in to comment.