Skip to content
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
16 changes: 16 additions & 0 deletions Zend/tests/bug62653.phpt
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
--TEST--
Bug #62653: unset($array[$float]) causes a crash
--FILE--
<?php

$array = array("5"=>"bar");
$foo = "10.0000"; // gettype($foo) = "string"
$foo /= 2; //Makes $foo = 5 but still gettype($foo) = "double"
unset($array[$foo]);
print_r($array);

?>
--EXPECT--
Array
(
)
3 changes: 2 additions & 1 deletion Zend/zend_vm_def.h
Original file line number Diff line number Diff line change
Expand Up @@ -3956,7 +3956,8 @@ ZEND_VM_HANDLER(75, ZEND_UNSET_DIM, VAR|UNUSED|CV, CONST|TMP|VAR|CV)
switch (Z_TYPE_P(offset)) {
case IS_DOUBLE:
hval = zend_dval_to_lval(Z_DVAL_P(offset));
ZEND_VM_C_GOTO(num_index_dim);
zend_hash_index_del(ht, hval);
break;
case IS_RESOURCE:
case IS_BOOL:
case IS_LONG:
Expand Down
36 changes: 24 additions & 12 deletions Zend/zend_vm_execute.h
Original file line number Diff line number Diff line change
Expand Up @@ -14166,7 +14166,8 @@ static int ZEND_FASTCALL ZEND_UNSET_DIM_SPEC_VAR_CONST_HANDLER(ZEND_OPCODE_HAND
switch (Z_TYPE_P(offset)) {
case IS_DOUBLE:
hval = zend_dval_to_lval(Z_DVAL_P(offset));
goto num_index_dim;
zend_hash_index_del(ht, hval);
break;
case IS_RESOURCE:
case IS_BOOL:
case IS_LONG:
Expand Down Expand Up @@ -16177,7 +16178,8 @@ static int ZEND_FASTCALL ZEND_UNSET_DIM_SPEC_VAR_TMP_HANDLER(ZEND_OPCODE_HANDLE
switch (Z_TYPE_P(offset)) {
case IS_DOUBLE:
hval = zend_dval_to_lval(Z_DVAL_P(offset));
goto num_index_dim;
zend_hash_index_del(ht, hval);
break;
case IS_RESOURCE:
case IS_BOOL:
case IS_LONG:
Expand Down Expand Up @@ -18398,7 +18400,8 @@ static int ZEND_FASTCALL ZEND_UNSET_DIM_SPEC_VAR_VAR_HANDLER(ZEND_OPCODE_HANDLE
switch (Z_TYPE_P(offset)) {
case IS_DOUBLE:
hval = zend_dval_to_lval(Z_DVAL_P(offset));
goto num_index_dim;
zend_hash_index_del(ht, hval);
break;
case IS_RESOURCE:
case IS_BOOL:
case IS_LONG:
Expand Down Expand Up @@ -21442,7 +21445,8 @@ static int ZEND_FASTCALL ZEND_UNSET_DIM_SPEC_VAR_CV_HANDLER(ZEND_OPCODE_HANDLER
switch (Z_TYPE_P(offset)) {
case IS_DOUBLE:
hval = zend_dval_to_lval(Z_DVAL_P(offset));
goto num_index_dim;
zend_hash_index_del(ht, hval);
break;
case IS_RESOURCE:
case IS_BOOL:
case IS_LONG:
Expand Down Expand Up @@ -22780,7 +22784,8 @@ static int ZEND_FASTCALL ZEND_UNSET_DIM_SPEC_UNUSED_CONST_HANDLER(ZEND_OPCODE_H
switch (Z_TYPE_P(offset)) {
case IS_DOUBLE:
hval = zend_dval_to_lval(Z_DVAL_P(offset));
goto num_index_dim;
zend_hash_index_del(ht, hval);
break;
case IS_RESOURCE:
case IS_BOOL:
case IS_LONG:
Expand Down Expand Up @@ -23938,7 +23943,8 @@ static int ZEND_FASTCALL ZEND_UNSET_DIM_SPEC_UNUSED_TMP_HANDLER(ZEND_OPCODE_HAN
switch (Z_TYPE_P(offset)) {
case IS_DOUBLE:
hval = zend_dval_to_lval(Z_DVAL_P(offset));
goto num_index_dim;
zend_hash_index_del(ht, hval);
break;
case IS_RESOURCE:
case IS_BOOL:
case IS_LONG:
Expand Down Expand Up @@ -25096,7 +25102,8 @@ static int ZEND_FASTCALL ZEND_UNSET_DIM_SPEC_UNUSED_VAR_HANDLER(ZEND_OPCODE_HAN
switch (Z_TYPE_P(offset)) {
case IS_DOUBLE:
hval = zend_dval_to_lval(Z_DVAL_P(offset));
goto num_index_dim;
zend_hash_index_del(ht, hval);
break;
case IS_RESOURCE:
case IS_BOOL:
case IS_LONG:
Expand Down Expand Up @@ -26520,7 +26527,8 @@ static int ZEND_FASTCALL ZEND_UNSET_DIM_SPEC_UNUSED_CV_HANDLER(ZEND_OPCODE_HAND
switch (Z_TYPE_P(offset)) {
case IS_DOUBLE:
hval = zend_dval_to_lval(Z_DVAL_P(offset));
goto num_index_dim;
zend_hash_index_del(ht, hval);
break;
case IS_RESOURCE:
case IS_BOOL:
case IS_LONG:
Expand Down Expand Up @@ -29783,7 +29791,8 @@ static int ZEND_FASTCALL ZEND_UNSET_DIM_SPEC_CV_CONST_HANDLER(ZEND_OPCODE_HANDL
switch (Z_TYPE_P(offset)) {
case IS_DOUBLE:
hval = zend_dval_to_lval(Z_DVAL_P(offset));
goto num_index_dim;
zend_hash_index_del(ht, hval);
break;
case IS_RESOURCE:
case IS_BOOL:
case IS_LONG:
Expand Down Expand Up @@ -31665,7 +31674,8 @@ static int ZEND_FASTCALL ZEND_UNSET_DIM_SPEC_CV_TMP_HANDLER(ZEND_OPCODE_HANDLER
switch (Z_TYPE_P(offset)) {
case IS_DOUBLE:
hval = zend_dval_to_lval(Z_DVAL_P(offset));
goto num_index_dim;
zend_hash_index_del(ht, hval);
break;
case IS_RESOURCE:
case IS_BOOL:
case IS_LONG:
Expand Down Expand Up @@ -33756,7 +33766,8 @@ static int ZEND_FASTCALL ZEND_UNSET_DIM_SPEC_CV_VAR_HANDLER(ZEND_OPCODE_HANDLER
switch (Z_TYPE_P(offset)) {
case IS_DOUBLE:
hval = zend_dval_to_lval(Z_DVAL_P(offset));
goto num_index_dim;
zend_hash_index_del(ht, hval);
break;
case IS_RESOURCE:
case IS_BOOL:
case IS_LONG:
Expand Down Expand Up @@ -36531,7 +36542,8 @@ static int ZEND_FASTCALL ZEND_UNSET_DIM_SPEC_CV_CV_HANDLER(ZEND_OPCODE_HANDLER_
switch (Z_TYPE_P(offset)) {
case IS_DOUBLE:
hval = zend_dval_to_lval(Z_DVAL_P(offset));
goto num_index_dim;
zend_hash_index_del(ht, hval);
break;
case IS_RESOURCE:
case IS_BOOL:
case IS_LONG:
Expand Down