summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorAnatol Belski <ab@php.net>2017-08-02 16:41:48 +0200
committerAnatol Belski <ab@php.net>2017-08-02 16:41:48 +0200
commit1fdc51897195fb4b7993260ab5d85e11e416f12e (patch)
tree572443976cb25cba67c5f374e100b3f1ea7c60a7
parent5f030924c19a39c09b57d40615f754cf80ae0e7d (diff)
parentb112d09013088e73676eee77f04a906d15fbd1a7 (diff)
downloadphp-git-1fdc51897195fb4b7993260ab5d85e11e416f12e.tar.gz
Merge branch 'PHP-7.0' into PHP-7.1
* PHP-7.0: Fixed bug #75002 Null Pointer Dereference in timelib_time_clone
-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