summaryrefslogtreecommitdiff
path: root/Zend
diff options
context:
space:
mode:
authorDmitry Stogov <dmitry@zend.com>2018-08-29 23:40:17 +0300
committerDmitry Stogov <dmitry@zend.com>2018-08-29 23:40:17 +0300
commit709e4e4f17ddbeb99b366c293c3e2eaa16480a7a (patch)
tree33c32ba9dba1d2a361a84d5a51f88f3de67872c3 /Zend
parent5fee4e71088a9827e4ca2d27975941be3b07d695 (diff)
downloadphp-git-709e4e4f17ddbeb99b366c293c3e2eaa16480a7a.tar.gz
Fixed incorrect ZEND_ACC_ARENA_ALLOCATED usage (it must be used only for internal functions).
Diffstat (limited to 'Zend')
-rw-r--r--Zend/zend_inheritance.c13
1 files changed, 9 insertions, 4 deletions
diff --git a/Zend/zend_inheritance.c b/Zend/zend_inheritance.c
index 16c8f9d659..b0c1f0ac37 100644
--- a/Zend/zend_inheritance.c
+++ b/Zend/zend_inheritance.c
@@ -1224,10 +1224,15 @@ static void zend_add_trait_method(zend_class_entry *ce, const char *name, zend_s
}
}
- function_add_ref(fn);
- new_fn = zend_arena_alloc(&CG(arena), sizeof(zend_op_array));
- memcpy(new_fn, fn, sizeof(zend_op_array));
- new_fn->common.fn_flags |= ZEND_ACC_ARENA_ALLOCATED;
+ if (UNEXPECTED(fn->type == ZEND_INTERNAL_FUNCTION)) {
+ new_fn = zend_arena_alloc(&CG(arena), sizeof(zend_internal_function));
+ memcpy(new_fn, fn, sizeof(zend_internal_function));
+ new_fn->common.fn_flags |= ZEND_ACC_ARENA_ALLOCATED;
+ } else {
+ function_add_ref(fn);
+ new_fn = zend_arena_alloc(&CG(arena), sizeof(zend_op_array));
+ memcpy(new_fn, fn, sizeof(zend_op_array));
+ }
fn = zend_hash_update_ptr(&ce->function_table, key, new_fn);
zend_add_magic_methods(ce, key, fn);
}