diff --git a/ext/standard/array.c b/ext/standard/array.c index cabafaaa67edf..7fdc26ccf4afe 100644 --- a/ext/standard/array.c +++ b/ext/standard/array.c @@ -6556,32 +6556,25 @@ PHP_FUNCTION(array_filter) if (!string_key) { ZVAL_LONG(key, num_key); } else { - ZVAL_STR_COPY(key, string_key); + ZVAL_STR(key, string_key); } } if (use_type != ARRAY_FILTER_USE_KEY) { - ZVAL_COPY(&args[0], operand); + ZVAL_COPY_VALUE(&args[0], operand); } fci.params = args; - if (zend_call_function(&fci, &fci_cache) == SUCCESS) { - bool retval_true; + zend_result result = zend_call_function(&fci, &fci_cache); + ZEND_ASSERT(result == SUCCESS); - zval_ptr_dtor(&args[0]); - if (use_type == ARRAY_FILTER_USE_BOTH) { - zval_ptr_dtor(&args[1]); - } - retval_true = zend_is_true(&retval); - zval_ptr_dtor(&retval); - if (!retval_true) { - continue; - } - } else { - zval_ptr_dtor(&args[0]); - if (use_type == ARRAY_FILTER_USE_BOTH) { - zval_ptr_dtor(&args[1]); - } - return; + if (UNEXPECTED(EG(exception))) { + RETURN_THROWS(); + } + + bool retval_true = zend_is_true(&retval); + zval_ptr_dtor(&retval); + if (!retval_true) { + continue; } } else if (!zend_is_true(operand)) { continue; @@ -6629,42 +6622,34 @@ static zend_result php_array_find(const HashTable *array, zend_fcall_info fci, z if (!str_key) { ZVAL_LONG(&args[1], num_key); } else { - ZVAL_STR_COPY(&args[1], str_key); + ZVAL_STR(&args[1], str_key); } - ZVAL_COPY(&args[0], operand); + ZVAL_COPY_VALUE(&args[0], operand); zend_result result = zend_call_function(&fci, &fci_cache); - if (EXPECTED(result == SUCCESS)) { - int retval_true; + ZEND_ASSERT(result == SUCCESS); - retval_true = zend_is_true(&retval); - zval_ptr_dtor(&retval); - - /* This negates the condition, if negate_condition is true. Otherwise it does nothing with `retval_true`. */ - retval_true ^= negate_condition; - - if (retval_true) { - if (result_value != NULL) { - ZVAL_COPY_DEREF(result_value, &args[0]); - } + if (UNEXPECTED(EG(exception))) { + return FAILURE; + } - if (result_key != NULL) { - ZVAL_COPY(result_key, &args[1]); - } + bool retval_true = zend_is_true(&retval); + zval_ptr_dtor(&retval); - zval_ptr_dtor(&args[0]); - zval_ptr_dtor(&args[1]); + /* This negates the condition, if negate_condition is true. Otherwise it does nothing with `retval_true`. */ + retval_true ^= negate_condition; - return SUCCESS; + if (retval_true) { + if (result_value != NULL) { + ZVAL_COPY_DEREF(result_value, &args[0]); } - } - zval_ptr_dtor(&args[0]); - zval_ptr_dtor(&args[1]); + if (result_key != NULL) { + ZVAL_COPY(result_key, &args[1]); + } - if (UNEXPECTED(result != SUCCESS)) { - return FAILURE; + break; } } ZEND_HASH_FOREACH_END();