Skip to content

Commit 7959b2d

Browse files
committed
Fix for Bug #23951
1 parent cdac440 commit 7959b2d

File tree

1 file changed

+12
-5
lines changed

1 file changed

+12
-5
lines changed

Zend/zend_execute_API.c

Lines changed: 12 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -439,7 +439,7 @@ ZEND_API int zval_update_constant(zval **pp, void *arg TSRMLS_DC)
439439
INIT_PZVAL(p);
440440
p->refcount = refcount;
441441
} else if (p->type == IS_CONSTANT_ARRAY) {
442-
zval **element;
442+
zval **element, *new_val;
443443
char *str_index;
444444
uint str_index_len;
445445
ulong num_index;
@@ -474,14 +474,21 @@ ZEND_API int zval_update_constant(zval **pp, void *arg TSRMLS_DC)
474474
continue;
475475
}
476476

477+
ALLOC_ZVAL(new_val);
478+
*new_val = **element;
479+
zval_copy_ctor(new_val);
480+
new_val->refcount = 1;
481+
new_val->is_ref = 0;
482+
483+
/* preserve this bit for inheritance */
484+
Z_TYPE_PP(element) |= IS_CONSTANT_INDEX;
485+
477486
switch (const_value.type) {
478487
case IS_STRING:
479-
zend_hash_update(p->value.ht, const_value.value.str.val, const_value.value.str.len+1, element, sizeof(zval *), NULL);
480-
(*element)->refcount++;
488+
zend_hash_update(p->value.ht, const_value.value.str.val, const_value.value.str.len+1, &new_val, sizeof(zval *), NULL);
481489
break;
482490
case IS_LONG:
483-
zend_hash_index_update(p->value.ht, const_value.value.lval, element, sizeof(zval *), NULL);
484-
(*element)->refcount++;
491+
zend_hash_index_update(p->value.ht, const_value.value.lval, &new_val, sizeof(zval *), NULL);
485492
break;
486493
}
487494
zend_hash_del(p->value.ht, str_index, str_index_len);

0 commit comments

Comments
 (0)