Skip to content

Commit d509040

Browse files
committed
fix(zend): use-after-free?
Signed-off-by: azjezz <azjezz@protonmail.com>
1 parent cf42de8 commit d509040

2 files changed

Lines changed: 9 additions & 0 deletions

File tree

Zend/zend_inheritance.c

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1958,6 +1958,7 @@ static void do_inherit_property(zend_property_info *parent_info, zend_string *ke
19581958
zend_function *clone_fn = zend_arena_alloc(&CG(arena), sizeof(zend_op_array));
19591959
memcpy(clone_fn, orig, sizeof(zend_op_array));
19601960
clone_fn->op_array.arg_info = new_arg_info + 1;
1961+
function_add_ref(clone_fn);
19611962

19621963
clone_hooks[hi] = clone_fn;
19631964
}

Zend/zend_opcode.c

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -597,6 +597,14 @@ ZEND_API void destroy_zend_class(zval *zv)
597597
}
598598
}
599599
}
600+
} else if (prop_info->flags & ZEND_ACC_GENERIC_CLONE) {
601+
if (prop_info->hooks) {
602+
for (uint32_t i = 0; i < ZEND_PROPERTY_HOOK_COUNT; i++) {
603+
if (prop_info->hooks[i]) {
604+
destroy_op_array(&prop_info->hooks[i]->op_array);
605+
}
606+
}
607+
}
600608
}
601609
} ZEND_HASH_FOREACH_END();
602610
zend_hash_destroy(&ce->properties_info);

0 commit comments

Comments
 (0)