From: Xinchen Hui Date: Thu, 21 Jan 2016 05:30:41 +0000 (+0800) Subject: Fixed bug #71413 (Crash with constants on internal interfaces) X-Git-Tag: php-7.2.0alpha1~620^2~100 X-Git-Url: https://granicus.if.org/sourcecode?a=commitdiff_plain;h=62c1c11ad34103729988df9edea343337a900ba9;p=php Fixed bug #71413 (Crash with constants on internal interfaces) --- diff --git a/Zend/zend_inheritance.c b/Zend/zend_inheritance.c index c4b22849dd..2226f6013d 100644 --- a/Zend/zend_inheritance.c +++ b/Zend/zend_inheritance.c @@ -933,13 +933,20 @@ static zend_bool do_inherit_constant_check(HashTable *child_constants_table, zen static void do_inherit_iface_constant(zend_string *name, zend_class_constant *c, zend_class_entry *ce, zend_class_entry *iface) /* {{{ */ { if (do_inherit_constant_check(&ce->constants_table, c, name, iface)) { + zend_class_constant *ct; if (Z_REFCOUNTED(c->value)) { Z_ADDREF(c->value); } if (Z_CONSTANT(c->value)) { ce->ce_flags &= ~ZEND_ACC_CONSTANTS_UPDATED; } - zend_hash_update_ptr(&ce->constants_table, name, c); + if (ce->type & ZEND_INTERNAL_CLASS) { + ct = pemalloc(sizeof(zend_class_constant), 1); + } else { + ct = zend_arena_alloc(&CG(arena), sizeof(zend_class_constant)); + } + memcpy(ct, c, sizeof(zend_class_constant)); + zend_hash_update_ptr(&ce->constants_table, name, ct); } } /* }}} */