Fixed unset() bug that was introduced with CV optimization patch

This commit is contained in:
Dmitry Stogov 2004-10-05 09:09:18 +00:00
parent 3f35c6a6cc
commit 3d383e45dc
3 changed files with 29 additions and 1 deletions

View File

@ -0,0 +1,21 @@
--TEST--
unset() CV 11 (unset() of copy destoies original value)
--FILE--
<?php
$x = array("default"=>"ok");
var_dump($x);
$cf = $x;
unset($cf['default']);
var_dump($x);
echo "ok\n";
?>
--EXPECT--
array(1) {
["default"]=>
string(2) "ok"
}
array(1) {
["default"]=>
string(2) "ok"
}
ok

View File

@ -195,6 +195,7 @@ static inline zval *_get_zval_ptr(znode *node, temp_variable *Ts, zend_free_op *
if (zend_hash_quick_find(EG(active_symbol_table), cv->name, cv->name_len+1, cv->hash_value, (void **)ptr)==FAILURE) {
switch (type) {
case BP_VAR_R:
case BP_VAR_UNSET:
zend_error(E_NOTICE, "Undefined variable: %s", cv->name);
/* break missing intentionally */
case BP_VAR_IS:
@ -228,6 +229,7 @@ static inline zval **_get_zval_ptr_ptr(znode *node, temp_variable *Ts, zend_free
if (zend_hash_quick_find(EG(active_symbol_table), cv->name, cv->name_len+1, cv->hash_value, (void **)ptr)==FAILURE) {
switch (type) {
case BP_VAR_R:
case BP_VAR_UNSET:
zend_error(E_NOTICE, "Undefined variable: %s", cv->name);
/* break missing intentionally */
case BP_VAR_IS:
@ -315,6 +317,7 @@ static inline zval *_get_zval_ptr_cv(znode *node, temp_variable *Ts, zend_free_o
if (zend_hash_quick_find(EG(active_symbol_table), cv->name, cv->name_len+1, cv->hash_value, (void **)ptr)==FAILURE) {
switch (type) {
case BP_VAR_R:
case BP_VAR_UNSET:
zend_error(E_NOTICE, "Undefined variable: %s", cv->name);
/* break missing intentionally */
case BP_VAR_IS:
@ -373,6 +376,7 @@ static inline zval **_get_zval_ptr_ptr_cv(znode *node, temp_variable *Ts, zend_f
if (zend_hash_quick_find(EG(active_symbol_table), cv->name, cv->name_len+1, cv->hash_value, (void **)ptr)==FAILURE) {
switch (type) {
case BP_VAR_R:
case BP_VAR_UNSET:
zend_error(E_NOTICE, "Undefined variable: %s", cv->name);
/* break missing intentionally */
case BP_VAR_IS:

View File

@ -3238,13 +3238,16 @@ ZEND_VM_HANDLER(ZEND_UNSET_DIM_OBJ)
{
zend_op *opline = EX(opline);
zend_free_op free_op1, free_op2;
zval **container = GET_OP1_OBJ_ZVAL_PTR_PTR(BP_VAR_R);
zval **container = GET_OP1_OBJ_ZVAL_PTR_PTR(BP_VAR_UNSET);
zval *offset = GET_OP2_ZVAL_PTR(BP_VAR_R);
long index;
if (container) {
HashTable *ht;
if (OP1_TYPE == IS_CV && container != &EG(uninitialized_zval_ptr)) {
SEPARATE_ZVAL_IF_NOT_REF(container);
}
if (opline->extended_value == ZEND_UNSET_DIM) {
switch (Z_TYPE_PP(container)) {
case IS_ARRAY: