summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorXinchen Hui <laruence@gmail.com>2018-05-23 14:45:38 +0800
committerXinchen Hui <laruence@gmail.com>2018-05-23 14:45:38 +0800
commit8f221bdec0e1a81ef4471f926cf0b0f23724204c (patch)
treedc47fb8fc419491c0652e844d852d0e7e810263c
parent68c3d09c2c1b88eafcf8b82af24f77756fd1d77f (diff)
downloadphp-git-8f221bdec0e1a81ef4471f926cf0b0f23724204c.tar.gz
Fixed bug #76367 (NoRewindIterator segfault 11)
-rw-r--r--NEWS3
-rw-r--r--ext/spl/spl_array.c2
-rw-r--r--ext/spl/tests/bug76367.phpt16
3 files changed, 20 insertions, 1 deletions
diff --git a/NEWS b/NEWS
index b872a7fd89..695f69346a 100644
--- a/NEWS
+++ b/NEWS
@@ -12,6 +12,9 @@ PHP NEWS
. Fixed bug #76174 (openssl extension fails to build with LibreSSL 2.7).
(Jakub Zelenka)
+- SPL:
+ . Fixed bug #76367 (NoRewindIterator segfault 11). (Laruence)
+
- Standard:
. Fixed bug #76335 ("link(): Bad file descriptor" with non-ASCII path).
(Anatol)
diff --git a/ext/spl/spl_array.c b/ext/spl/spl_array.c
index 8abb3ba7ed..0a3032263c 100644
--- a/ext/spl/spl_array.c
+++ b/ext/spl/spl_array.c
@@ -1039,7 +1039,7 @@ static zval *spl_array_it_get_current_data(zend_object_iterator *iter) /* {{{ */
return zend_user_it_get_current_data(iter);
} else {
zval *data = zend_hash_get_current_data_ex(aht, spl_array_get_pos_ptr(aht, object));
- if (Z_TYPE_P(data) == IS_INDIRECT) {
+ if (data && Z_TYPE_P(data) == IS_INDIRECT) {
data = Z_INDIRECT_P(data);
}
return data;
diff --git a/ext/spl/tests/bug76367.phpt b/ext/spl/tests/bug76367.phpt
new file mode 100644
index 0000000000..f34e8a39de
--- /dev/null
+++ b/ext/spl/tests/bug76367.phpt
@@ -0,0 +1,16 @@
+--TEST--
+Bug #76367 (NoRewindIterator segfault 11)
+--FILE--
+<?php
+$arr = [1,3,55,66,43,6];
+
+$iter = new NoRewindIterator(new ArrayIterator($arr));
+
+while($iter->valid()) {
+ $iter->next();
+}
+
+var_dump($iter->current());
+?>
+--EXPECT--
+NULL