diff --git a/ext/spl/spl_array.c b/ext/spl/spl_array.c index bc883b02e6f..d34902ce807 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 00000000000..f34e8a39def --- /dev/null +++ b/ext/spl/tests/bug76367.phpt @@ -0,0 +1,16 @@ +--TEST-- +Bug #76367 (NoRewindIterator segfault 11) +--FILE-- +valid()) { + $iter->next(); +} + +var_dump($iter->current()); +?> +--EXPECT-- +NULL