Skip to content

Commit fc92a40

Browse files
committed
Do not duplicate the attributes table in zend_get_call_trampoline_func()
1 parent 22dc09c commit fc92a40

File tree

2 files changed

+6
-4
lines changed

2 files changed

+6
-4
lines changed

Zend/zend_object_handlers.c

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1619,7 +1619,8 @@ ZEND_API zend_function *zend_get_call_trampoline_func(const zend_class_entry *ce
16191619
| ZEND_ACC_VARIADIC
16201620
| (fbc->common.fn_flags & (ZEND_ACC_RETURN_REFERENCE|ZEND_ACC_DEPRECATED));
16211621
if (fbc->common.attributes) {
1622-
func->attributes = zend_array_dup(fbc->common.attributes);
1622+
func->attributes = fbc->common.attributes;
1623+
GC_TRY_ADDREF(func->attributes);
16231624
} else {
16241625
func->attributes = NULL;
16251626
}

Zend/zend_object_handlers.h

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -339,11 +339,12 @@ ZEND_API bool ZEND_FASTCALL zend_asymmetric_property_has_set_access(const zend_p
339339
} while (0)
340340

341341
#define zend_free_trampoline(func) do { \
342-
if ((func)->common.attributes) { \
343-
zend_array_destroy((func)->common.attributes); \
344-
(func)->common.attributes = NULL; \
342+
HashTable *attributes = (func)->common.attributes; \
343+
if (attributes && !(GC_FLAGS(attributes) & GC_IMMUTABLE) && !GC_DELREF(attributes)) { \
344+
zend_array_destroy(attributes); \
345345
} \
346346
if ((func) == &EG(trampoline)) { \
347+
EG(trampoline).common.attributes = NULL; \
347348
EG(trampoline).common.function_name = NULL; \
348349
} else { \
349350
efree(func); \

0 commit comments

Comments
 (0)