Skip to content

Commit fd5a453

Browse files
committed
Merge branch 'PHP-7.1' into PHP-7.2
* PHP-7.1: Fixed incorrect ZEND_ACC_ARENA_ALLOCATED usage (it must be used only for internal functions).
2 parents 7881e92 + 709e4e4 commit fd5a453

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
@@ -1209,10 +1209,15 @@ static void zend_add_trait_method(zend_class_entry *ce, const char *name, zend_s
12091209
}
12101210
}
12111211

1212-
function_add_ref(fn);
1213-
new_fn = zend_arena_alloc(&CG(arena), sizeof(zend_op_array));
1214-
memcpy(new_fn, fn, sizeof(zend_op_array));
1215-
new_fn->common.fn_flags |= ZEND_ACC_ARENA_ALLOCATED;
1212+
if (UNEXPECTED(fn->type == ZEND_INTERNAL_FUNCTION)) {
1213+
new_fn = zend_arena_alloc(&CG(arena), sizeof(zend_internal_function));
1214+
memcpy(new_fn, fn, sizeof(zend_internal_function));
1215+
new_fn->common.fn_flags |= ZEND_ACC_ARENA_ALLOCATED;
1216+
} else {
1217+
function_add_ref(fn);
1218+
new_fn = zend_arena_alloc(&CG(arena), sizeof(zend_op_array));
1219+
memcpy(new_fn, fn, sizeof(zend_op_array));
1220+
}
12161221
fn = zend_hash_update_ptr(&ce->function_table, key, new_fn);
12171222
zend_add_magic_methods(ce, key, fn);
12181223
}

0 commit comments

Comments
 (0)