Skip to content

Commit 9a16533

Browse files
committed
Merge branch 'PHP-8.1'
* PHP-8.1: Fix ext/zend_test/tests/observer_bug81430_2.phpt failure
2 parents a8ccbaf + f6d7f78 commit 9a16533

File tree

1 file changed

+29
-19
lines changed

1 file changed

+29
-19
lines changed

ext/reflection/php_reflection.c

Lines changed: 29 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -6522,9 +6522,7 @@ static int call_attribute_constructor(
65226522
zval *args, uint32_t argc, HashTable *named_params, zend_string *filename)
65236523
{
65246524
zend_function *ctor = ce->constructor;
6525-
zend_execute_data *prev_execute_data, dummy_frame;
6526-
zend_function dummy_func;
6527-
zend_op dummy_opline;
6525+
zend_execute_data *call = NULL;
65286526
ZEND_ASSERT(ctor != NULL);
65296527

65306528
if (!(ctor->common.fn_flags & ZEND_ACC_PUBLIC)) {
@@ -6535,31 +6533,43 @@ static int call_attribute_constructor(
65356533
if (filename) {
65366534
/* Set up dummy call frame that makes it look like the attribute was invoked
65376535
* from where it occurs in the code. */
6538-
memset(&dummy_frame, 0, sizeof(zend_execute_data));
6539-
memset(&dummy_func, 0, sizeof(zend_function));
6540-
memset(&dummy_opline, 0, sizeof(zend_op));
6536+
zend_function dummy_func;
6537+
zend_op *opline;
65416538

6542-
prev_execute_data = EG(current_execute_data);
6543-
dummy_frame.prev_execute_data = prev_execute_data;
6544-
dummy_frame.func = &dummy_func;
6545-
dummy_frame.opline = &dummy_opline;
6539+
memset(&dummy_func, 0, sizeof(zend_function));
65466540

6547-
dummy_func.type = ZEND_USER_FUNCTION;
6548-
dummy_func.common.fn_flags =
6541+
call = zend_vm_stack_push_call_frame_ex(
6542+
ZEND_MM_ALIGNED_SIZE_EX(sizeof(zend_execute_data), sizeof(zval)) +
6543+
ZEND_MM_ALIGNED_SIZE_EX(sizeof(zend_op), sizeof(zval)) +
6544+
ZEND_MM_ALIGNED_SIZE_EX(sizeof(zend_function), sizeof(zval)),
6545+
0, &dummy_func, 0, NULL);
6546+
6547+
opline = (zend_op*)(call + 1);
6548+
memset(opline, 0, sizeof(zend_op));
6549+
opline->opcode = ZEND_DO_FCALL;
6550+
opline->lineno = attr->lineno;
6551+
6552+
call->opline = opline;
6553+
call->call = NULL;
6554+
call->return_value = NULL;
6555+
call->func = (zend_function*)(call->opline + 1);
6556+
call->prev_execute_data = EG(current_execute_data);
6557+
6558+
memset(call->func, 0, sizeof(zend_function));
6559+
call->func->type = ZEND_USER_FUNCTION;
6560+
call->func->op_array.fn_flags =
65496561
attr->flags & ZEND_ATTRIBUTE_STRICT_TYPES ? ZEND_ACC_STRICT_TYPES : 0;
6550-
dummy_func.common.fn_flags |= ZEND_ACC_CALL_VIA_TRAMPOLINE;
6551-
dummy_func.op_array.filename = filename;
6552-
6553-
dummy_opline.opcode = ZEND_DO_FCALL;
6554-
dummy_opline.lineno = attr->lineno;
6562+
call->func->op_array.fn_flags |= ZEND_ACC_CALL_VIA_TRAMPOLINE;
6563+
call->func->op_array.filename = filename;
65556564

6556-
EG(current_execute_data) = &dummy_frame;
6565+
EG(current_execute_data) = call;
65576566
}
65586567

65596568
zend_call_known_function(ctor, obj, obj->ce, NULL, argc, args, named_params);
65606569

65616570
if (filename) {
6562-
EG(current_execute_data) = prev_execute_data;
6571+
EG(current_execute_data) = call->prev_execute_data;
6572+
zend_vm_stack_free_call_frame(call);
65636573
}
65646574

65656575
if (EG(exception)) {

0 commit comments

Comments
 (0)