Skip to content

Commit 709e4e4

Browse files
committed
Fixed incorrect ZEND_ACC_ARENA_ALLOCATED usage (it must be used only for internal functions).
1 parent 5fee4e7 commit 709e4e4

File tree

1 file changed

+9
-4
lines changed

1 file changed

+9
-4
lines changed

Zend/zend_inheritance.c

Lines changed: 9 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1224,10 +1224,15 @@ static void zend_add_trait_method(zend_class_entry *ce, const char *name, zend_s
12241224
}
12251225
}
12261226

1227-
function_add_ref(fn);
1228-
new_fn = zend_arena_alloc(&CG(arena), sizeof(zend_op_array));
1229-
memcpy(new_fn, fn, sizeof(zend_op_array));
1230-
new_fn->common.fn_flags |= ZEND_ACC_ARENA_ALLOCATED;
1227+
if (UNEXPECTED(fn->type == ZEND_INTERNAL_FUNCTION)) {
1228+
new_fn = zend_arena_alloc(&CG(arena), sizeof(zend_internal_function));
1229+
memcpy(new_fn, fn, sizeof(zend_internal_function));
1230+
new_fn->common.fn_flags |= ZEND_ACC_ARENA_ALLOCATED;
1231+
} else {
1232+
function_add_ref(fn);
1233+
new_fn = zend_arena_alloc(&CG(arena), sizeof(zend_op_array));
1234+
memcpy(new_fn, fn, sizeof(zend_op_array));
1235+
}
12311236
fn = zend_hash_update_ptr(&ce->function_table, key, new_fn);
12321237
zend_add_magic_methods(ce, key, fn);
12331238
}

0 commit comments

Comments
 (0)