diff options
author | Xinchen Hui <laruence@gmail.com> | 2018-05-23 14:45:38 +0800 |
---|---|---|
committer | Xinchen Hui <laruence@gmail.com> | 2018-05-23 14:45:38 +0800 |
commit | 8f221bdec0e1a81ef4471f926cf0b0f23724204c (patch) | |
tree | dc47fb8fc419491c0652e844d852d0e7e810263c | |
parent | 68c3d09c2c1b88eafcf8b82af24f77756fd1d77f (diff) | |
download | php-git-8f221bdec0e1a81ef4471f926cf0b0f23724204c.tar.gz |
Fixed bug #76367 (NoRewindIterator segfault 11)
-rw-r--r-- | NEWS | 3 | ||||
-rw-r--r-- | ext/spl/spl_array.c | 2 | ||||
-rw-r--r-- | ext/spl/tests/bug76367.phpt | 16 |
3 files changed, 20 insertions, 1 deletions
@@ -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 |