com php-src: Fixed bug #75002 Null Pointer Dereference in timelib_time_clone: ext/date/php_date.c ext/date/ tests/bug75002.phpt
| From: | Anatol Belski | Date: | Wed, 02 Aug 2017 14:40:48 +0000 |
| Subject: | com php-src: Fixed bug #75002 Null Pointer Dereference in timelib_time_clone: ext/date/php_date.c ext/date/ tests/bug75002.phpt | ||
| Groups: | php.cvs | ||
| Request: | Send a blank email to php-cvs+get-98911@lists.php.net to get a copy of this message | ||
Commit: b112d09013088e73676eee77f04a906d15fbd1a7
Author: Derick Rethans <derick@php.net> Wed, 2 Aug 2017 16:40:48 +0200
Committer: Anatol Belski <ab@php.net> Wed, 2 Aug 2017 16:40:48 +0200
Parents: 666cb6c80226467be262c088a26246c48cdef7e5
Branches: PHP-7.0 PHP-7.1 PHP-7..2 master
Link: http://git.php.net/?p=php-src.git;a=commitdiff;h=b112d09013088e73676eee77f04a906d15fbd1a7
Log:
Fixed bug #75002 Null Pointer Dereference in timelib_time_clone
Bugs:
https://bugs.php.net/75002
Changed paths:
M ext/date/php_date.c
A ext/date/tests/bug75002.phpt
Diff:
diff --git a/ext/date/php_date.c b/ext/date/php_date.c
index f671f4c..e3d0c5a 100644
--- a/ext/date/php_date..c
+++ b/ext/date/php_date.c
@@ -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);
}
diff --git a/ext/date/tests/bug75002.phpt b/ext/date/tests/bug75002.phpt
new file mode 100644
index 0000000..6a6cd21
--- /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