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 @@ -833,7 +833,15 @@ static zend_string* ZEND_FASTCALL zend_jit_fetch_dim_str_r_helper(zend_string *s
833
833
zend_long offset ;
834
834
835
835
if (UNEXPECTED (Z_TYPE_P (dim ) != IS_LONG )) {
836
+ if (!(GC_FLAGS (str ) & IS_STR_INTERNED )) {
837
+ GC_ADDREF (str );
838
+ }
836
839
offset = zend_check_string_offset (dim /*, BP_VAR_R*/ );
840
+ if (!(GC_FLAGS (str ) & IS_STR_INTERNED ) && UNEXPECTED (GC_DELREF (str ) == 0 )) {
841
+ zend_string * ret = zend_jit_fetch_dim_str_offset (str , offset );
842
+ zend_string_efree (str );
843
+ return ret ;
844
+ }
837
845
} else {
838
846
offset = Z_LVAL_P (dim );
839
847
}
You can’t perform that action at this time.
0 commit comments