Skip to content

Commit f7c3f6e

Browse files
committed
Fix ext/zend_test/tests/observer_bug81430_2.phpt failure
1 parent 522406c commit f7c3f6e

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
@@ -6290,9 +6290,7 @@ static int call_attribute_constructor(
62906290
zval *args, uint32_t argc, HashTable *named_params, zend_string *filename)
62916291
{
62926292
zend_function *ctor = ce->constructor;
6293-
zend_execute_data *prev_execute_data, dummy_frame;
6294-
zend_function dummy_func;
6295-
zend_op dummy_opline;
6293+
zend_execute_data *call = NULL;
62966294
ZEND_ASSERT(ctor != NULL);
62976295

62986296
if (!(ctor->common.fn_flags & ZEND_ACC_PUBLIC)) {
@@ -6303,31 +6301,43 @@ static int call_attribute_constructor(
63036301
if (filename) {
63046302
/* Set up dummy call frame that makes it look like the attribute was invoked
63056303
* from where it occurs in the code. */
6306-
memset(&dummy_frame, 0, sizeof(zend_execute_data));
6307-
memset(&dummy_func, 0, sizeof(zend_function));
6308-
memset(&dummy_opline, 0, sizeof(zend_op));
6304+
zend_function dummy_func;
6305+
zend_op *opline;
63096306

6310-
prev_execute_data = EG(current_execute_data);
6311-
dummy_frame.prev_execute_data = prev_execute_data;
6312-
dummy_frame.func = &dummy_func;
6313-
dummy_frame.opline = &dummy_opline;
6307+
memset(&dummy_func, 0, sizeof(zend_function));
63146308

6315-
dummy_func.type = ZEND_USER_FUNCTION;
6316-
dummy_func.common.fn_flags =
6309+
call = zend_vm_stack_push_call_frame_ex(
6310+
ZEND_MM_ALIGNED_SIZE_EX(sizeof(zend_execute_data), sizeof(zval)) +
6311+
ZEND_MM_ALIGNED_SIZE_EX(sizeof(zend_op), sizeof(zval)) +
6312+
ZEND_MM_ALIGNED_SIZE_EX(sizeof(zend_function), sizeof(zval)),
6313+
0, &dummy_func, 0, NULL);
6314+
6315+
opline = (zend_op*)(call + 1);
6316+
memset(opline, 0, sizeof(zend_op));
6317+
opline->opcode = ZEND_DO_FCALL;
6318+
opline->lineno = attr->lineno;
6319+
6320+
call->opline = opline;
6321+
call->call = NULL;
6322+
call->return_value = NULL;
6323+
call->func = (zend_function*)(call->opline + 1);
6324+
call->prev_execute_data = EG(current_execute_data);
6325+
6326+
memset(call->func, 0, sizeof(zend_function));
6327+
call->func->type = ZEND_USER_FUNCTION;
6328+
call->func->op_array.fn_flags =
63176329
attr->flags & ZEND_ATTRIBUTE_STRICT_TYPES ? ZEND_ACC_STRICT_TYPES : 0;
6318-
dummy_func.common.fn_flags |= ZEND_ACC_CALL_VIA_TRAMPOLINE;
6319-
dummy_func.op_array.filename = filename;
6320-
6321-
dummy_opline.opcode = ZEND_DO_FCALL;
6322-
dummy_opline.lineno = attr->lineno;
6330+
call->func->op_array.fn_flags |= ZEND_ACC_CALL_VIA_TRAMPOLINE;
6331+
call->func->op_array.filename = filename;
63236332

6324-
EG(current_execute_data) = &dummy_frame;
6333+
EG(current_execute_data) = call;
63256334
}
63266335

63276336
zend_call_known_function(ctor, obj, obj->ce, NULL, argc, args, named_params);
63286337

63296338
if (filename) {
6330-
EG(current_execute_data) = prev_execute_data;
6339+
EG(current_execute_data) = call->prev_execute_data;
6340+
zend_vm_stack_free_call_frame(call);
63316341
}
63326342

63336343
if (EG(exception)) {

0 commit comments

Comments
 (0)