Skip to content

Commit ab9a40f

Browse files
committed
Added support for preloaded classes/functions in ZTS build
1 parent e3c65db commit ab9a40f

File tree

2 files changed

+9
-2
lines changed

2 files changed

+9
-2
lines changed

Zend/zend.c

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -566,8 +566,13 @@ static void auto_global_dtor(zval *zv) /* {{{ */
566566
static void function_copy_ctor(zval *zv) /* {{{ */
567567
{
568568
zend_function *old_func = Z_FUNC_P(zv);
569-
zend_function *func = pemalloc(sizeof(zend_internal_function), 1);
569+
zend_function *func;
570570

571+
if (old_func->type == ZEND_USER_FUNCTION) {
572+
ZEND_ASSERT(old_func->op_array.fn_flags & ZEND_ACC_IMMUTABLE);
573+
return;
574+
}
575+
func = pemalloc(sizeof(zend_internal_function), 1);
571576
Z_FUNC_P(zv) = func;
572577
memcpy(func, old_func, sizeof(zend_internal_function));
573578
function_add_ref(func);

Zend/zend_opcode.c

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -362,7 +362,9 @@ void zend_class_add_ref(zval *zv)
362362
{
363363
zend_class_entry *ce = Z_PTR_P(zv);
364364

365-
ce->refcount++;
365+
if (!(ce->ce_flags & ZEND_ACC_IMMUTABLE)) {
366+
ce->refcount++;
367+
}
366368
}
367369

368370
ZEND_API void destroy_op_array(zend_op_array *op_array)

0 commit comments

Comments
 (0)