summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--ext/date/php_date.c4
-rw-r--r--ext/date/tests/bug75002.phpt22
2 files changed, 26 insertions, 0 deletions
diff --git a/ext/date/php_date.c b/ext/date/php_date.c
index dcc71a402b..fb98fab893 100644
--- a/ext/date/php_date.c
+++ b/ext/date/php_date.c
@@ -1944,6 +1944,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);
}
diff --git a/ext/date/tests/bug75002.phpt b/ext/date/tests/bug75002.phpt
new file mode 100644
index 0000000000..6a6cd21d03
--- /dev/null
+++ b/ext/date/tests/bug75002.phpt
@@ -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