mirror of
https://github.com/php/php-src.git
synced 2026-03-24 08:12:21 +01:00
@@ -1017,7 +1017,7 @@ PHP_METHOD(MultipleIterator, rewind)
|
||||
zend_hash_internal_pointer_reset_ex(&intern->storage, &intern->pos);
|
||||
while ((element = zend_hash_get_current_data_ptr_ex(&intern->storage, &intern->pos)) != NULL && !EG(exception)) {
|
||||
zend_object *it = element->obj;
|
||||
zend_call_method_with_0_params(it, it->ce, &it->ce->iterator_funcs_ptr->zf_rewind, "rewind", NULL);
|
||||
zend_call_method_with_0_params(it, it->ce, it->ce->iterator_funcs_ptr ? &it->ce->iterator_funcs_ptr->zf_rewind : NULL, "rewind", NULL);
|
||||
zend_hash_move_forward_ex(&intern->storage, &intern->pos);
|
||||
}
|
||||
}
|
||||
@@ -1038,7 +1038,7 @@ PHP_METHOD(MultipleIterator, next)
|
||||
zend_hash_internal_pointer_reset_ex(&intern->storage, &intern->pos);
|
||||
while ((element = zend_hash_get_current_data_ptr_ex(&intern->storage, &intern->pos)) != NULL && !EG(exception)) {
|
||||
zend_object *it = element->obj;
|
||||
zend_call_method_with_0_params(it, it->ce, &it->ce->iterator_funcs_ptr->zf_next, "next", NULL);
|
||||
zend_call_method_with_0_params(it, it->ce, it->ce->iterator_funcs_ptr ? &it->ce->iterator_funcs_ptr->zf_next : NULL, "next", NULL);
|
||||
zend_hash_move_forward_ex(&intern->storage, &intern->pos);
|
||||
}
|
||||
}
|
||||
@@ -1067,7 +1067,7 @@ PHP_METHOD(MultipleIterator, valid)
|
||||
zend_hash_internal_pointer_reset_ex(&intern->storage, &intern->pos);
|
||||
while ((element = zend_hash_get_current_data_ptr_ex(&intern->storage, &intern->pos)) != NULL && !EG(exception)) {
|
||||
zend_object *it = element->obj;
|
||||
zend_call_method_with_0_params(it, it->ce, &it->ce->iterator_funcs_ptr->zf_valid, "valid", &retval);
|
||||
zend_call_method_with_0_params(it, it->ce, it->ce->iterator_funcs_ptr ? &it->ce->iterator_funcs_ptr->zf_valid : NULL, "valid", &retval);
|
||||
|
||||
if (!Z_ISUNDEF(retval)) {
|
||||
valid = (Z_TYPE(retval) == IS_TRUE);
|
||||
@@ -1105,7 +1105,7 @@ static void spl_multiple_iterator_get_all(spl_SplObjectStorage *intern, int get_
|
||||
zend_hash_internal_pointer_reset_ex(&intern->storage, &intern->pos);
|
||||
while ((element = zend_hash_get_current_data_ptr_ex(&intern->storage, &intern->pos)) != NULL && !EG(exception)) {
|
||||
zend_object *it = element->obj;
|
||||
zend_call_method_with_0_params(it, it->ce, &it->ce->iterator_funcs_ptr->zf_valid, "valid", &retval);
|
||||
zend_call_method_with_0_params(it, it->ce, it->ce->iterator_funcs_ptr ? &it->ce->iterator_funcs_ptr->zf_valid : NULL, "valid", &retval);
|
||||
|
||||
if (!Z_ISUNDEF(retval)) {
|
||||
valid = Z_TYPE(retval) == IS_TRUE;
|
||||
@@ -1116,9 +1116,9 @@ static void spl_multiple_iterator_get_all(spl_SplObjectStorage *intern, int get_
|
||||
|
||||
if (valid) {
|
||||
if (SPL_MULTIPLE_ITERATOR_GET_ALL_CURRENT == get_type) {
|
||||
zend_call_method_with_0_params(it, it->ce, &it->ce->iterator_funcs_ptr->zf_current, "current", &retval);
|
||||
zend_call_method_with_0_params(it, it->ce, it->ce->iterator_funcs_ptr ? &it->ce->iterator_funcs_ptr->zf_current : NULL, "current", &retval);
|
||||
} else {
|
||||
zend_call_method_with_0_params(it, it->ce, &it->ce->iterator_funcs_ptr->zf_key, "key", &retval);
|
||||
zend_call_method_with_0_params(it, it->ce, it->ce->iterator_funcs_ptr ? &it->ce->iterator_funcs_ptr->zf_key : NULL, "key", &retval);
|
||||
}
|
||||
if (Z_ISUNDEF(retval)) {
|
||||
zend_throw_exception(spl_ce_RuntimeException, "Failed to call sub iterator method", 0);
|
||||
|
||||
18
ext/spl/tests/bug81587.phpt
Normal file
18
ext/spl/tests/bug81587.phpt
Normal file
@@ -0,0 +1,18 @@
|
||||
--TEST--
|
||||
Bug #81587: MultipleIterator Segmentation fault w/ SimpleXMLElement attached
|
||||
--EXTENSIONS--
|
||||
simplexml
|
||||
--FILE--
|
||||
<?php
|
||||
$mi = new MultipleIterator();
|
||||
$mi->attachIterator(new SimpleXMLElement('<x><y/></x>'));
|
||||
foreach ($mi as $v) {
|
||||
var_dump($v);
|
||||
}
|
||||
?>
|
||||
--EXPECT--
|
||||
array(1) {
|
||||
[0]=>
|
||||
object(SimpleXMLElement)#4 (0) {
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user