dmitry Wed, 06 Jul 2011 12:04:02 +0000 Revision: http://svn.php.net/viewvc?view=revision&revision=313005
Log: Fixed bug #55135 (Array keys are no longer type casted in unset()) Bug: https://bugs.php.net/55135 (Assigned) Array keys are no longer type casted in unset() Changed paths: A php/php-src/branches/PHP_5_4/Zend/tests/bug55135.phpt U php/php-src/branches/PHP_5_4/Zend/zend_vm_def.h U php/php-src/branches/PHP_5_4/Zend/zend_vm_execute.h A php/php-src/trunk/Zend/tests/bug55135.phpt U php/php-src/trunk/Zend/zend_vm_def.h U php/php-src/trunk/Zend/zend_vm_execute.h
Added: php/php-src/branches/PHP_5_4/Zend/tests/bug55135.phpt =================================================================== --- php/php-src/branches/PHP_5_4/Zend/tests/bug55135.phpt (rev 0) +++ php/php-src/branches/PHP_5_4/Zend/tests/bug55135.phpt 2011-07-06 12:04:02 UTC (rev 313005) @@ -0,0 +1,38 @@ +--TEST-- +Bug #55135 (Array keys are no longer type casted in unset()) +--FILE-- +<?php +// This fails. +$array = array(1 => 2); +$a = "1"; +unset($array[$a]); +print_r($array); + +// Those works. +$array = array(1 => 2); +$a = 1; +unset($array[$a]); +print_r($array); + +$array = array(1 => 2); +unset($array[1]); +print_r($array); + +$array = array(1 => 2); +$a = 1; +unset($array["1"]); +print_r($array); +?> +--EXPECT-- +Array +( +) +Array +( +) +Array +( +) +Array +( +) Modified: php/php-src/branches/PHP_5_4/Zend/zend_vm_def.h =================================================================== --- php/php-src/branches/PHP_5_4/Zend/zend_vm_def.h 2011-07-06 11:27:32 UTC (rev 313004) +++ php/php-src/branches/PHP_5_4/Zend/zend_vm_def.h 2011-07-06 12:04:02 UTC (rev 313005) @@ -3917,7 +3917,6 @@ case IS_RESOURCE: case IS_BOOL: case IS_LONG: -ZEND_VM_C_LABEL(num_index_dim): hval = Z_LVAL_P(offset); zend_hash_index_del(ht, hval); break; @@ -3944,6 +3943,12 @@ zval_ptr_dtor(&offset); } break; +ZEND_VM_C_LABEL(num_index_dim): + zend_hash_index_del(ht, hval); + if (OP2_TYPE == IS_CV || OP2_TYPE == IS_VAR) { + zval_ptr_dtor(&offset); + } + break; case IS_NULL: zend_hash_del(ht, "", sizeof("")); break; Modified: php/php-src/branches/PHP_5_4/Zend/zend_vm_execute.h =================================================================== --- php/php-src/branches/PHP_5_4/Zend/zend_vm_execute.h 2011-07-06 11:27:32 UTC (rev 313004) +++ php/php-src/branches/PHP_5_4/Zend/zend_vm_execute.h 2011-07-06 12:04:02 UTC (rev 313005) @@ -13526,7 +13526,6 @@ case IS_RESOURCE: case IS_BOOL: case IS_LONG: -num_index_dim: hval = Z_LVAL_P(offset); zend_hash_index_del(ht, hval); break; @@ -13553,6 +13552,12 @@ zval_ptr_dtor(&offset); } break; +num_index_dim: + zend_hash_index_del(ht, hval); + if (IS_CONST == IS_CV || IS_CONST == IS_VAR) { + zval_ptr_dtor(&offset); + } + break; case IS_NULL: zend_hash_del(ht, "", sizeof("")); break; @@ -15506,7 +15511,6 @@ case IS_RESOURCE: case IS_BOOL: case IS_LONG: -num_index_dim: hval = Z_LVAL_P(offset); zend_hash_index_del(ht, hval); break; @@ -15533,6 +15537,12 @@ zval_ptr_dtor(&offset); } break; +num_index_dim: + zend_hash_index_del(ht, hval); + if (IS_TMP_VAR == IS_CV || IS_TMP_VAR == IS_VAR) { + zval_ptr_dtor(&offset); + } + break; case IS_NULL: zend_hash_del(ht, "", sizeof("")); break; @@ -17682,7 +17692,6 @@ case IS_RESOURCE: case IS_BOOL: case IS_LONG: -num_index_dim: hval = Z_LVAL_P(offset); zend_hash_index_del(ht, hval); break; @@ -17709,6 +17718,12 @@ zval_ptr_dtor(&offset); } break; +num_index_dim: + zend_hash_index_del(ht, hval); + if (IS_VAR == IS_CV || IS_VAR == IS_VAR) { + zval_ptr_dtor(&offset); + } + break; case IS_NULL: zend_hash_del(ht, "", sizeof("")); break; @@ -20670,7 +20685,6 @@ case IS_RESOURCE: case IS_BOOL: case IS_LONG: -num_index_dim: hval = Z_LVAL_P(offset); zend_hash_index_del(ht, hval); break; @@ -20697,6 +20711,12 @@ zval_ptr_dtor(&offset); } break; +num_index_dim: + zend_hash_index_del(ht, hval); + if (IS_CV == IS_CV || IS_CV == IS_VAR) { + zval_ptr_dtor(&offset); + } + break; case IS_NULL: zend_hash_del(ht, "", sizeof("")); break; @@ -21992,7 +22012,6 @@ case IS_RESOURCE: case IS_BOOL: case IS_LONG: -num_index_dim: hval = Z_LVAL_P(offset); zend_hash_index_del(ht, hval); break; @@ -22019,6 +22038,12 @@ zval_ptr_dtor(&offset); } break; +num_index_dim: + zend_hash_index_del(ht, hval); + if (IS_CONST == IS_CV || IS_CONST == IS_VAR) { + zval_ptr_dtor(&offset); + } + break; case IS_NULL: zend_hash_del(ht, "", sizeof("")); break; @@ -23135,7 +23160,6 @@ case IS_RESOURCE: case IS_BOOL: case IS_LONG: -num_index_dim: hval = Z_LVAL_P(offset); zend_hash_index_del(ht, hval); break; @@ -23162,6 +23186,12 @@ zval_ptr_dtor(&offset); } break; +num_index_dim: + zend_hash_index_del(ht, hval); + if (IS_TMP_VAR == IS_CV || IS_TMP_VAR == IS_VAR) { + zval_ptr_dtor(&offset); + } + break; case IS_NULL: zend_hash_del(ht, "", sizeof("")); break; @@ -24278,7 +24308,6 @@ case IS_RESOURCE: case IS_BOOL: case IS_LONG: -num_index_dim: hval = Z_LVAL_P(offset); zend_hash_index_del(ht, hval); break; @@ -24305,6 +24334,12 @@ zval_ptr_dtor(&offset); } break; +num_index_dim: + zend_hash_index_del(ht, hval); + if (IS_VAR == IS_CV || IS_VAR == IS_VAR) { + zval_ptr_dtor(&offset); + } + break; case IS_NULL: zend_hash_del(ht, "", sizeof("")); break; @@ -25687,7 +25722,6 @@ case IS_RESOURCE: case IS_BOOL: case IS_LONG: -num_index_dim: hval = Z_LVAL_P(offset); zend_hash_index_del(ht, hval); break; @@ -25714,6 +25748,12 @@ zval_ptr_dtor(&offset); } break; +num_index_dim: + zend_hash_index_del(ht, hval); + if (IS_CV == IS_CV || IS_CV == IS_VAR) { + zval_ptr_dtor(&offset); + } + break; case IS_NULL: zend_hash_del(ht, "", sizeof("")); break; @@ -28838,7 +28878,6 @@ case IS_RESOURCE: case IS_BOOL: case IS_LONG: -num_index_dim: hval = Z_LVAL_P(offset); zend_hash_index_del(ht, hval); break; @@ -28865,6 +28904,12 @@ zval_ptr_dtor(&offset); } break; +num_index_dim: + zend_hash_index_del(ht, hval); + if (IS_CONST == IS_CV || IS_CONST == IS_VAR) { + zval_ptr_dtor(&offset); + } + break; case IS_NULL: zend_hash_del(ht, "", sizeof("")); break; @@ -30692,7 +30737,6 @@ case IS_RESOURCE: case IS_BOOL: case IS_LONG: -num_index_dim: hval = Z_LVAL_P(offset); zend_hash_index_del(ht, hval); break; @@ -30719,6 +30763,12 @@ zval_ptr_dtor(&offset); } break; +num_index_dim: + zend_hash_index_del(ht, hval); + if (IS_TMP_VAR == IS_CV || IS_TMP_VAR == IS_VAR) { + zval_ptr_dtor(&offset); + } + break; case IS_NULL: zend_hash_del(ht, "", sizeof("")); break; @@ -32741,7 +32791,6 @@ case IS_RESOURCE: case IS_BOOL: case IS_LONG: -num_index_dim: hval = Z_LVAL_P(offset); zend_hash_index_del(ht, hval); break; @@ -32768,6 +32817,12 @@ zval_ptr_dtor(&offset); } break; +num_index_dim: + zend_hash_index_del(ht, hval); + if (IS_VAR == IS_CV || IS_VAR == IS_VAR) { + zval_ptr_dtor(&offset); + } + break; case IS_NULL: zend_hash_del(ht, "", sizeof("")); break; @@ -35466,7 +35521,6 @@ case IS_RESOURCE: case IS_BOOL: case IS_LONG: -num_index_dim: hval = Z_LVAL_P(offset); zend_hash_index_del(ht, hval); break; @@ -35493,6 +35547,12 @@ zval_ptr_dtor(&offset); } break; +num_index_dim: + zend_hash_index_del(ht, hval); + if (IS_CV == IS_CV || IS_CV == IS_VAR) { + zval_ptr_dtor(&offset); + } + break; case IS_NULL: zend_hash_del(ht, "", sizeof("")); break; Added: php/php-src/trunk/Zend/tests/bug55135.phpt =================================================================== --- php/php-src/trunk/Zend/tests/bug55135.phpt (rev 0) +++ php/php-src/trunk/Zend/tests/bug55135.phpt 2011-07-06 12:04:02 UTC (rev 313005) @@ -0,0 +1,38 @@ +--TEST-- +Bug #55135 (Array keys are no longer type casted in unset()) +--FILE-- +<?php +// This fails. +$array = array(1 => 2); +$a = "1"; +unset($array[$a]); +print_r($array); + +// Those works. +$array = array(1 => 2); +$a = 1; +unset($array[$a]); +print_r($array); + +$array = array(1 => 2); +unset($array[1]); +print_r($array); + +$array = array(1 => 2); +$a = 1; +unset($array["1"]); +print_r($array); +?> +--EXPECT-- +Array +( +) +Array +( +) +Array +( +) +Array +( +) Modified: php/php-src/trunk/Zend/zend_vm_def.h =================================================================== --- php/php-src/trunk/Zend/zend_vm_def.h 2011-07-06 11:27:32 UTC (rev 313004) +++ php/php-src/trunk/Zend/zend_vm_def.h 2011-07-06 12:04:02 UTC (rev 313005) @@ -3917,7 +3917,6 @@ case IS_RESOURCE: case IS_BOOL: case IS_LONG: -ZEND_VM_C_LABEL(num_index_dim): hval = Z_LVAL_P(offset); zend_hash_index_del(ht, hval); break; @@ -3944,6 +3943,12 @@ zval_ptr_dtor(&offset); } break; +ZEND_VM_C_LABEL(num_index_dim): + zend_hash_index_del(ht, hval); + if (OP2_TYPE == IS_CV || OP2_TYPE == IS_VAR) { + zval_ptr_dtor(&offset); + } + break; case IS_NULL: zend_hash_del(ht, "", sizeof("")); break; Modified: php/php-src/trunk/Zend/zend_vm_execute.h =================================================================== --- php/php-src/trunk/Zend/zend_vm_execute.h 2011-07-06 11:27:32 UTC (rev 313004) +++ php/php-src/trunk/Zend/zend_vm_execute.h 2011-07-06 12:04:02 UTC (rev 313005) @@ -13526,7 +13526,6 @@ case IS_RESOURCE: case IS_BOOL: case IS_LONG: -num_index_dim: hval = Z_LVAL_P(offset); zend_hash_index_del(ht, hval); break; @@ -13553,6 +13552,12 @@ zval_ptr_dtor(&offset); } break; +num_index_dim: + zend_hash_index_del(ht, hval); + if (IS_CONST == IS_CV || IS_CONST == IS_VAR) { + zval_ptr_dtor(&offset); + } + break; case IS_NULL: zend_hash_del(ht, "", sizeof("")); break; @@ -15506,7 +15511,6 @@ case IS_RESOURCE: case IS_BOOL: case IS_LONG: -num_index_dim: hval = Z_LVAL_P(offset); zend_hash_index_del(ht, hval); break; @@ -15533,6 +15537,12 @@ zval_ptr_dtor(&offset); } break; +num_index_dim: + zend_hash_index_del(ht, hval); + if (IS_TMP_VAR == IS_CV || IS_TMP_VAR == IS_VAR) { + zval_ptr_dtor(&offset); + } + break; case IS_NULL: zend_hash_del(ht, "", sizeof("")); break; @@ -17682,7 +17692,6 @@ case IS_RESOURCE: case IS_BOOL: case IS_LONG: -num_index_dim: hval = Z_LVAL_P(offset); zend_hash_index_del(ht, hval); break; @@ -17709,6 +17718,12 @@ zval_ptr_dtor(&offset); } break; +num_index_dim: + zend_hash_index_del(ht, hval); + if (IS_VAR == IS_CV || IS_VAR == IS_VAR) { + zval_ptr_dtor(&offset); + } + break; case IS_NULL: zend_hash_del(ht, "", sizeof("")); break; @@ -20670,7 +20685,6 @@ case IS_RESOURCE: case IS_BOOL: case IS_LONG: -num_index_dim: hval = Z_LVAL_P(offset); zend_hash_index_del(ht, hval); break; @@ -20697,6 +20711,12 @@ zval_ptr_dtor(&offset); } break; +num_index_dim: + zend_hash_index_del(ht, hval); + if (IS_CV == IS_CV || IS_CV == IS_VAR) { + zval_ptr_dtor(&offset); + } + break; case IS_NULL: zend_hash_del(ht, "", sizeof("")); break; @@ -21992,7 +22012,6 @@ case IS_RESOURCE: case IS_BOOL: case IS_LONG: -num_index_dim: hval = Z_LVAL_P(offset); zend_hash_index_del(ht, hval); break; @@ -22019,6 +22038,12 @@ zval_ptr_dtor(&offset); } break; +num_index_dim: + zend_hash_index_del(ht, hval); + if (IS_CONST == IS_CV || IS_CONST == IS_VAR) { + zval_ptr_dtor(&offset); + } + break; case IS_NULL: zend_hash_del(ht, "", sizeof("")); break; @@ -23135,7 +23160,6 @@ case IS_RESOURCE: case IS_BOOL: case IS_LONG: -num_index_dim: hval = Z_LVAL_P(offset); zend_hash_index_del(ht, hval); break; @@ -23162,6 +23186,12 @@ zval_ptr_dtor(&offset); } break; +num_index_dim: + zend_hash_index_del(ht, hval); + if (IS_TMP_VAR == IS_CV || IS_TMP_VAR == IS_VAR) { + zval_ptr_dtor(&offset); + } + break; case IS_NULL: zend_hash_del(ht, "", sizeof("")); break; @@ -24278,7 +24308,6 @@ case IS_RESOURCE: case IS_BOOL: case IS_LONG: -num_index_dim: hval = Z_LVAL_P(offset); zend_hash_index_del(ht, hval); break; @@ -24305,6 +24334,12 @@ zval_ptr_dtor(&offset); } break; +num_index_dim: + zend_hash_index_del(ht, hval); + if (IS_VAR == IS_CV || IS_VAR == IS_VAR) { + zval_ptr_dtor(&offset); + } + break; case IS_NULL: zend_hash_del(ht, "", sizeof("")); break; @@ -25687,7 +25722,6 @@ case IS_RESOURCE: case IS_BOOL: case IS_LONG: -num_index_dim: hval = Z_LVAL_P(offset); zend_hash_index_del(ht, hval); break; @@ -25714,6 +25748,12 @@ zval_ptr_dtor(&offset); } break; +num_index_dim: + zend_hash_index_del(ht, hval); + if (IS_CV == IS_CV || IS_CV == IS_VAR) { + zval_ptr_dtor(&offset); + } + break; case IS_NULL: zend_hash_del(ht, "", sizeof("")); break; @@ -28838,7 +28878,6 @@ case IS_RESOURCE: case IS_BOOL: case IS_LONG: -num_index_dim: hval = Z_LVAL_P(offset); zend_hash_index_del(ht, hval); break; @@ -28865,6 +28904,12 @@ zval_ptr_dtor(&offset); } break; +num_index_dim: + zend_hash_index_del(ht, hval); + if (IS_CONST == IS_CV || IS_CONST == IS_VAR) { + zval_ptr_dtor(&offset); + } + break; case IS_NULL: zend_hash_del(ht, "", sizeof("")); break; @@ -30692,7 +30737,6 @@ case IS_RESOURCE: case IS_BOOL: case IS_LONG: -num_index_dim: hval = Z_LVAL_P(offset); zend_hash_index_del(ht, hval); break; @@ -30719,6 +30763,12 @@ zval_ptr_dtor(&offset); } break; +num_index_dim: + zend_hash_index_del(ht, hval); + if (IS_TMP_VAR == IS_CV || IS_TMP_VAR == IS_VAR) { + zval_ptr_dtor(&offset); + } + break; case IS_NULL: zend_hash_del(ht, "", sizeof("")); break; @@ -32741,7 +32791,6 @@ case IS_RESOURCE: case IS_BOOL: case IS_LONG: -num_index_dim: hval = Z_LVAL_P(offset); zend_hash_index_del(ht, hval); break; @@ -32768,6 +32817,12 @@ zval_ptr_dtor(&offset); } break; +num_index_dim: + zend_hash_index_del(ht, hval); + if (IS_VAR == IS_CV || IS_VAR == IS_VAR) { + zval_ptr_dtor(&offset); + } + break; case IS_NULL: zend_hash_del(ht, "", sizeof("")); break; @@ -35466,7 +35521,6 @@ case IS_RESOURCE: case IS_BOOL: case IS_LONG: -num_index_dim: hval = Z_LVAL_P(offset); zend_hash_index_del(ht, hval); break; @@ -35493,6 +35547,12 @@ zval_ptr_dtor(&offset); } break; +num_index_dim: + zend_hash_index_del(ht, hval); + if (IS_CV == IS_CV || IS_CV == IS_VAR) { + zval_ptr_dtor(&offset); + } + break; case IS_NULL: zend_hash_del(ht, "", sizeof("")); break;
-- PHP CVS Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php