@@ -676,48 +676,56 @@ static zval* ZEND_FASTCALL zend_jit_fetch_dim_w_helper(zend_array *ht, zval *dim
676
676
return retval ;
677
677
}
678
678
679
- static void ZEND_FASTCALL zend_jit_fetch_dim_str_r_helper (zval * container , zval * dim , zval * result )
679
+ static zend_never_inline zend_long zend_check_string_offset (zval * dim /*, int type*/ )
680
680
{
681
681
zend_long offset ;
682
682
683
- try_string_offset :
684
- if (UNEXPECTED (Z_TYPE_P (dim ) != IS_LONG )) {
685
- switch (Z_TYPE_P (dim )) {
686
- case IS_STRING :
687
- {
688
- bool trailing_data = false;
689
- /* For BC reasons we allow errors so that we can warn on leading numeric string */
690
- if (IS_LONG == is_numeric_string_ex (Z_STRVAL_P (dim ), Z_STRLEN_P (dim ), & offset , NULL ,
691
- /* allow errors */ true, NULL , & trailing_data )) {
692
- if (UNEXPECTED (trailing_data )) {
693
- zend_error (E_WARNING , "Illegal string offset \"%s\"" , Z_STRVAL_P (dim ));
694
- }
695
- goto out ;
683
+ try_again :
684
+ switch (Z_TYPE_P (dim )) {
685
+ case IS_LONG :
686
+ return Z_LVAL_P (dim );
687
+ case IS_STRING :
688
+ {
689
+ bool trailing_data = false;
690
+ /* For BC reasons we allow errors so that we can warn on leading numeric string */
691
+ if (IS_LONG == is_numeric_string_ex (Z_STRVAL_P (dim ), Z_STRLEN_P (dim ), & offset , NULL ,
692
+ /* allow errors */ true, NULL , & trailing_data )) {
693
+ if (UNEXPECTED (trailing_data ) /*&& type != BP_VAR_UNSET*/ ) {
694
+ zend_error (E_WARNING , "Illegal string offset \"%s\"" , Z_STRVAL_P (dim ));
696
695
}
697
- zend_jit_illegal_string_offset (dim );
698
- break ;
696
+ return offset ;
699
697
}
700
- case IS_UNDEF :
701
- zend_jit_undefined_op_helper (EG (current_execute_data )-> opline -> op2 .var );
702
- case IS_DOUBLE :
703
- case IS_NULL :
704
- case IS_FALSE :
705
- case IS_TRUE :
706
- zend_error (E_WARNING , "String offset cast occurred" );
707
- break ;
708
- case IS_REFERENCE :
709
- dim = Z_REFVAL_P (dim );
710
- goto try_string_offset ;
711
- default :
712
- zend_jit_illegal_string_offset (dim );
713
- break ;
698
+ zend_jit_illegal_string_offset (dim );
699
+ break ;
714
700
}
701
+ case IS_UNDEF :
702
+ zend_jit_undefined_op_helper (EG (current_execute_data )-> opline -> op2 .var );
703
+ case IS_DOUBLE :
704
+ case IS_NULL :
705
+ case IS_FALSE :
706
+ case IS_TRUE :
707
+ zend_error (E_WARNING , "String offset cast occurred" );
708
+ break ;
709
+ case IS_REFERENCE :
710
+ dim = Z_REFVAL_P (dim );
711
+ goto try_again ;
712
+ default :
713
+ zend_jit_illegal_string_offset (dim );
714
+ break ;
715
+ }
715
716
716
- offset = _zval_get_long_func (dim );
717
+ return _zval_get_long_func (dim );
718
+ }
719
+
720
+ static void ZEND_FASTCALL zend_jit_fetch_dim_str_r_helper (zval * container , zval * dim , zval * result )
721
+ {
722
+ zend_long offset ;
723
+
724
+ if (UNEXPECTED (Z_TYPE_P (dim ) != IS_LONG )) {
725
+ offset = zend_check_string_offset (dim /*, BP_VAR_R*/ );
717
726
} else {
718
727
offset = Z_LVAL_P (dim );
719
728
}
720
- out :
721
729
722
730
if (UNEXPECTED (Z_STRLEN_P (container ) < ((offset < 0 ) ? - (size_t )offset : ((size_t )offset + 1 )))) {
723
731
zend_error (E_WARNING , "Uninitialized string offset " ZEND_LONG_FMT , offset );
@@ -824,51 +832,6 @@ static void ZEND_FASTCALL zend_jit_fetch_dim_obj_is_helper(zval *container, zval
824
832
}
825
833
}
826
834
827
- static zend_never_inline zend_long zend_check_string_offset (zval * dim , int type )
828
- {
829
- zend_long offset ;
830
-
831
- try_again :
832
- if (UNEXPECTED (Z_TYPE_P (dim ) != IS_LONG )) {
833
- switch (Z_TYPE_P (dim )) {
834
- case IS_STRING :
835
- {
836
- bool trailing_data = false;
837
- /* For BC reasons we allow errors so that we can warn on leading numeric string */
838
- if (IS_LONG == is_numeric_string_ex (Z_STRVAL_P (dim ), Z_STRLEN_P (dim ), & offset , NULL ,
839
- /* allow errors */ true, NULL , & trailing_data )) {
840
- if (UNEXPECTED (trailing_data ) && type != BP_VAR_UNSET ) {
841
- zend_error (E_WARNING , "Illegal string offset \"%s\"" , Z_STRVAL_P (dim ));
842
- }
843
- return offset ;
844
- }
845
- zend_jit_illegal_string_offset (dim );
846
- break ;
847
- }
848
- case IS_UNDEF :
849
- zend_jit_undefined_op_helper (EG (current_execute_data )-> opline -> op2 .var );
850
- case IS_DOUBLE :
851
- case IS_NULL :
852
- case IS_FALSE :
853
- case IS_TRUE :
854
- zend_error (E_WARNING , "String offset cast occurred" );
855
- break ;
856
- case IS_REFERENCE :
857
- dim = Z_REFVAL_P (dim );
858
- goto try_again ;
859
- default :
860
- zend_jit_illegal_string_offset (dim );
861
- break ;
862
- }
863
-
864
- offset = _zval_get_long_func (dim );
865
- } else {
866
- offset = Z_LVAL_P (dim );
867
- }
868
-
869
- return offset ;
870
- }
871
-
872
835
static zend_never_inline ZEND_COLD void zend_wrong_string_offset (void )
873
836
{
874
837
const char * msg = NULL ;
@@ -975,7 +938,11 @@ static zend_never_inline void zend_assign_to_string_offset(zval *str, zval *dim,
975
938
size_t string_len ;
976
939
zend_long offset ;
977
940
978
- offset = zend_check_string_offset (dim , BP_VAR_W );
941
+ if (UNEXPECTED (Z_TYPE_P (dim ) != IS_LONG )) {
942
+ offset = zend_check_string_offset (dim /*, BP_VAR_W*/ );
943
+ } else {
944
+ offset = Z_LVAL_P (dim );
945
+ }
979
946
if (offset < - (zend_long )Z_STRLEN_P (str )) {
980
947
/* Error on negative offset */
981
948
zend_error (E_WARNING , "Illegal string offset " ZEND_LONG_FMT , offset );
@@ -1108,7 +1075,9 @@ static void ZEND_FASTCALL zend_jit_assign_dim_op_helper(zval *container, zval *d
1108
1075
if (!dim ) {
1109
1076
zend_throw_error (NULL , "[] operator not supported for strings" );
1110
1077
} else {
1111
- zend_check_string_offset (dim , BP_VAR_RW );
1078
+ if (UNEXPECTED (Z_TYPE_P (dim ) != IS_LONG )) {
1079
+ zend_check_string_offset (dim /*, BP_VAR_RW*/ );
1080
+ }
1112
1081
zend_wrong_string_offset ();
1113
1082
}
1114
1083
//??? } else if (EXPECTED(Z_TYPE_P(container) <= IS_FALSE)) {
0 commit comments