Skip to content
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
15 changes: 12 additions & 3 deletions Zend/zend_vm_execute.h
Original file line number Diff line number Diff line change
Expand Up @@ -38110,9 +38110,18 @@ static ZEND_OPCODE_HANDLER_RET ZEND_FASTCALL ZEND_FE_RESET_R_SPEC_CV_HANDLER(ZEN
} else {
properties = zobj->handlers->get_properties(zobj);
}
Z_FE_ITER_P(EX_VAR(opline->result.var)) = zend_hash_iterator_add(properties, 0);

ZEND_VM_NEXT_OPCODE_CHECK_EXCEPTION();
if (!properties) {
/* No properties to iterate over */
ZVAL_UNDEF(EX_VAR(opline->result.var));
Z_FE_ITER_P(EX_VAR(opline->result.var)) = (uint32_t)-1;
if (IS_CV != IS_TMP_VAR) {
GC_DELREF(zobj);
}
ZEND_VM_JMP(OP_JMP_ADDR(opline, opline->op2));
} else {
Z_FE_ITER_P(EX_VAR(opline->result.var)) = zend_hash_iterator_add(properties, 0);
ZEND_VM_NEXT_OPCODE_CHECK_EXCEPTION();
}
} else {
zend_bool is_empty = zend_fe_reset_iterator(array_ptr, 0 OPLINE_CC EXECUTE_DATA_CC);

Expand Down
2 changes: 1 addition & 1 deletion ext/ffi/ffi.c
Original file line number Diff line number Diff line change
Expand Up @@ -4644,7 +4644,7 @@ static ZEND_COLD zend_function *zend_fake_get_method(zend_object **obj_ptr, zend

static HashTable *zend_fake_get_properties(zend_object *obj) /* {{{ */
{
return (HashTable*)&zend_empty_array;
return NULL;
}
/* }}} */

Expand Down
14 changes: 14 additions & 0 deletions ext/ffi/tests/bug80186.phpt
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
--TEST--
Bug #80186 (Segfault when iterating over FFI object)
--SKIPIF--
<?php
if (!extension_loaded('ffi')) die('skip ffi extension not available');
?>
--FILE--
<?php
$ffi = FFI::cdef('typedef int dummy;');
foreach ($ffi as $_i) { }
echo "no segfault\n";
?>
--EXPECT--
no segfault