@@ -754,9 +754,10 @@ static inline zval **zend_fetch_dimension_address_inner(HashTable *ht, znode *op
754
754
fetch_string_dim :
755
755
if (zend_symtable_find (ht , offset_key , offset_key_length + 1 , (void * * ) & retval ) == FAILURE ) {
756
756
switch (type ) {
757
- case BP_VAR_R :
758
- zend_error (E_NOTICE ,"Undefined index: %s" , offset_key );
757
+ case BP_VAR_R :
758
+ zend_error (E_NOTICE , "Undefined index: %s" , offset_key );
759
759
/* break missing intentionally */
760
+ case BP_VAR_UNSET :
760
761
case BP_VAR_IS :
761
762
retval = & EG (uninitialized_zval_ptr );
762
763
break ;
@@ -786,9 +787,10 @@ static inline zval **zend_fetch_dimension_address_inner(HashTable *ht, znode *op
786
787
}
787
788
if (zend_hash_index_find (ht , index , (void * * ) & retval ) == FAILURE ) {
788
789
switch (type ) {
789
- case BP_VAR_R :
790
+ case BP_VAR_R :
790
791
zend_error (E_NOTICE ,"Undefined offset: %ld" , index );
791
792
/* break missing intentionally */
793
+ case BP_VAR_UNSET :
792
794
case BP_VAR_IS :
793
795
retval = & EG (uninitialized_zval_ptr );
794
796
break ;
@@ -808,10 +810,15 @@ static inline zval **zend_fetch_dimension_address_inner(HashTable *ht, znode *op
808
810
break ;
809
811
default :
810
812
zend_error (E_WARNING , "Illegal offset type" );
811
- if (type == BP_VAR_R || type == BP_VAR_IS ) {
812
- retval = & EG (uninitialized_zval_ptr );
813
- } else {
814
- retval = & EG (error_zval_ptr );
813
+ switch (type ) {
814
+ case BP_VAR_R :
815
+ case BP_VAR_IS :
816
+ case BP_VAR_UNSET :
817
+ retval = & EG (uninitialized_zval_ptr );
818
+ break ;
819
+ default :
820
+ retval = & EG (error_zval_ptr );
821
+ break ;
815
822
}
816
823
break ;
817
824
}
@@ -898,8 +905,15 @@ static void zend_fetch_dimension_address(znode *result, znode *op1, znode *op2,
898
905
convert_to_long (& tmp );
899
906
offset = & tmp ;
900
907
}
901
- if (type != BP_VAR_R && type != BP_VAR_IS ) {
902
- SEPARATE_ZVAL_IF_NOT_REF (container_ptr );
908
+ switch (type ) {
909
+ case BP_VAR_R :
910
+ case BP_VAR_IS :
911
+ case BP_VAR_UNSET :
912
+ /* do nothing... */
913
+ break ;
914
+ default :
915
+ SEPARATE_ZVAL_IF_NOT_REF (container_ptr );
916
+ break ;
903
917
}
904
918
container = * container_ptr ;
905
919
T (result -> u .var ).str_offset .str = container ;
@@ -933,10 +947,18 @@ static void zend_fetch_dimension_address(znode *result, znode *op1, znode *op2,
933
947
break ;
934
948
default : {
935
949
get_zval_ptr (op2 , Ts , & EG (free_op2 ), BP_VAR_R );
936
- if (type == BP_VAR_R || type == BP_VAR_IS ) {
937
- * retval = & EG (uninitialized_zval_ptr );
938
- } else {
939
- * retval = & EG (error_zval_ptr );
950
+
951
+ switch (type ) {
952
+ case BP_VAR_UNSET :
953
+ zend_error (E_WARNING , "Cannot unset offset in a non-array variable" );
954
+ /* break missing intentionally */
955
+ case BP_VAR_R :
956
+ case BP_VAR_IS :
957
+ * retval = & EG (uninitialized_zval_ptr );
958
+ break ;
959
+ default :
960
+ * retval = & EG (error_zval_ptr );
961
+ break ;
940
962
}
941
963
FREE_OP (Ts , op2 , EG (free_op2 ));
942
964
SELECTIVE_PZVAL_LOCK (* * retval , result );
@@ -1970,7 +1992,7 @@ int zend_fetch_dim_unset_handler(ZEND_OPCODE_HANDLER_ARGS)
1970
1992
PZVAL_LOCK(*EX_T(opline->op1.u.var).var.ptr_ptr);
1971
1993
}
1972
1994
*/
1973
- zend_fetch_dimension_address (& opline -> result , & opline -> op1 , & opline -> op2 , EX (Ts ), BP_VAR_R TSRMLS_CC );
1995
+ zend_fetch_dimension_address (& opline -> result , & opline -> op1 , & opline -> op2 , EX (Ts ), BP_VAR_UNSET TSRMLS_CC );
1974
1996
if (EX_T (opline -> result .u .var ).var .ptr_ptr == NULL ) {
1975
1997
zend_error (E_ERROR , "Cannot unset string offsets" );
1976
1998
} else {
0 commit comments