Skip to content

Commit 62c1c11

Browse files
committed
Fixed bug #71413 (Crash with constants on internal interfaces)
1 parent dcf3db6 commit 62c1c11

File tree

1 file changed

+8
-1
lines changed

1 file changed

+8
-1
lines changed

Zend/zend_inheritance.c

Lines changed: 8 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -933,13 +933,20 @@ static zend_bool do_inherit_constant_check(HashTable *child_constants_table, zen
933933
static void do_inherit_iface_constant(zend_string *name, zend_class_constant *c, zend_class_entry *ce, zend_class_entry *iface) /* {{{ */
934934
{
935935
if (do_inherit_constant_check(&ce->constants_table, c, name, iface)) {
936+
zend_class_constant *ct;
936937
if (Z_REFCOUNTED(c->value)) {
937938
Z_ADDREF(c->value);
938939
}
939940
if (Z_CONSTANT(c->value)) {
940941
ce->ce_flags &= ~ZEND_ACC_CONSTANTS_UPDATED;
941942
}
942-
zend_hash_update_ptr(&ce->constants_table, name, c);
943+
if (ce->type & ZEND_INTERNAL_CLASS) {
944+
ct = pemalloc(sizeof(zend_class_constant), 1);
945+
} else {
946+
ct = zend_arena_alloc(&CG(arena), sizeof(zend_class_constant));
947+
}
948+
memcpy(ct, c, sizeof(zend_class_constant));
949+
zend_hash_update_ptr(&ce->constants_table, name, ct);
943950
}
944951
}
945952
/* }}} */

0 commit comments

Comments
 (0)