Fixed support for constant arrays in context of "const" statement (Zend/tests/constant_expressions_arrays.phpt failed when opcache.protect_memort was set)

This commit is contained in:
Dmitry Stogov 2014-07-23 22:47:58 +04:00
parent a6ecb873b9
commit c49a06168e
2 changed files with 20 additions and 0 deletions

View File

@ -5387,6 +5387,16 @@ ZEND_VM_HANDLER(143, ZEND_DECLARE_CONST, CONST, CONST)
c.value = *tmp_ptr;
} else {
INIT_PZVAL_COPY(&c.value, val);
if (Z_TYPE(c.value) == IS_ARRAY) {
HashTable *ht;
ALLOC_HASHTABLE(ht);
zend_hash_init(ht, zend_hash_num_elements(Z_ARRVAL(c.value)), NULL, ZVAL_PTR_DTOR, 0);
zend_hash_copy(ht, Z_ARRVAL(c.value), (copy_ctor_func_t) zval_deep_copy, NULL, sizeof(zval *));
Z_ARRVAL(c.value) = ht;
} else {
zval_copy_ctor(&c.value);
}
zval_copy_ctor(&c.value);
}
c.flags = CONST_CS; /* non persistent, case sensetive */

View File

@ -4323,6 +4323,16 @@ static int ZEND_FASTCALL ZEND_DECLARE_CONST_SPEC_CONST_CONST_HANDLER(ZEND_OPCOD
c.value = *tmp_ptr;
} else {
INIT_PZVAL_COPY(&c.value, val);
if (Z_TYPE(c.value) == IS_ARRAY) {
HashTable *ht;
ALLOC_HASHTABLE(ht);
zend_hash_init(ht, zend_hash_num_elements(Z_ARRVAL(c.value)), NULL, ZVAL_PTR_DTOR, 0);
zend_hash_copy(ht, Z_ARRVAL(c.value), (copy_ctor_func_t) zval_deep_copy, NULL, sizeof(zval *));
Z_ARRVAL(c.value) = ht;
} else {
zval_copy_ctor(&c.value);
}
zval_copy_ctor(&c.value);
}
c.flags = CONST_CS; /* non persistent, case sensetive */