File tree 2 files changed +26
-0
lines changed
2 files changed +26
-0
lines changed Original file line number Diff line number Diff line change
1
+ --TEST--
2
+ string offset 008 indirect string modification by error handler
3
+ --FILE--
4
+ <?php
5
+ set_error_handler (function ($ code , $ msg ) {
6
+ echo "Err: $ msg \n" ;
7
+ $ GLOBALS ['a ' ]=8 ;
8
+ });
9
+ $ z = "z " ;
10
+ $ a =["xx $ z " ];
11
+ var_dump ($ a [0 ][$ b ]);
12
+ var_dump ($ a );
13
+ ?>
14
+ --EXPECT--
15
+ Err: Undefined variable $b
16
+ Err: String offset cast occurred
17
+ string(1) "x"
18
+ int(8)
Original file line number Diff line number Diff line change @@ -921,7 +921,15 @@ static zend_string* ZEND_FASTCALL zend_jit_fetch_dim_str_r_helper(zend_string *s
921
921
zend_long offset ;
922
922
923
923
if (UNEXPECTED (Z_TYPE_P (dim ) != IS_LONG )) {
924
+ if (!(GC_FLAGS (str ) & IS_STR_INTERNED )) {
925
+ GC_ADDREF (str );
926
+ }
924
927
offset = zend_check_string_offset (dim /*, BP_VAR_R*/ );
928
+ if (!(GC_FLAGS (str ) & IS_STR_INTERNED ) && UNEXPECTED (GC_DELREF (str ) == 0 )) {
929
+ zend_string * ret = zend_jit_fetch_dim_str_offset (str , offset );
930
+ zend_string_efree (str );
931
+ return ret ;
932
+ }
925
933
} else {
926
934
offset = Z_LVAL_P (dim );
927
935
}
You can’t perform that action at this time.
0 commit comments