@@ -2141,7 +2141,7 @@ static uint32_t assign_dim_result_type(
21412141
21422142/* For binary ops that have compound assignment operators */
21432143static uint32_t binary_op_result_type (
2144- zend_ssa * ssa , zend_uchar opcode , uint32_t t1 , uint32_t t2 , uint32_t result_var ,
2144+ zend_ssa * ssa , zend_uchar opcode , uint32_t t1 , uint32_t t2 , int result_var ,
21452145 zend_long optimization_level ) {
21462146 uint32_t tmp = 0 ;
21472147 uint32_t t1_type = (t1 & MAY_BE_ANY ) | (t1 & MAY_BE_UNDEF ? MAY_BE_NULL : 0 );
@@ -2159,7 +2159,8 @@ static uint32_t binary_op_result_type(
21592159 switch (opcode ) {
21602160 case ZEND_ADD :
21612161 if (t1_type == MAY_BE_LONG && t2_type == MAY_BE_LONG ) {
2162- if (!ssa -> var_info [result_var ].has_range ||
2162+ if (result_var < 0 ||
2163+ !ssa -> var_info [result_var ].has_range ||
21632164 ssa -> var_info [result_var ].range .underflow ||
21642165 ssa -> var_info [result_var ].range .overflow ) {
21652166 /* may overflow */
@@ -2185,7 +2186,8 @@ static uint32_t binary_op_result_type(
21852186 case ZEND_SUB :
21862187 case ZEND_MUL :
21872188 if (t1_type == MAY_BE_LONG && t2_type == MAY_BE_LONG ) {
2188- if (!ssa -> var_info [result_var ].has_range ||
2189+ if (result_var < 0 ||
2190+ !ssa -> var_info [result_var ].has_range ||
21892191 ssa -> var_info [result_var ].range .underflow ||
21902192 ssa -> var_info [result_var ].range .overflow ) {
21912193 /* may overflow */
@@ -2627,7 +2629,8 @@ static int zend_update_type_info(const zend_op_array *op_array,
26272629 }
26282630
26292631 tmp |= binary_op_result_type (
2630- ssa , opline -> extended_value , t1 , t2 , ssa_ops [i ].op1_def , optimization_level );
2632+ ssa , opline -> extended_value , t1 , t2 ,
2633+ opline -> opcode == ZEND_ASSIGN_OP ? ssa_ops [i ].op1_def : -1 , optimization_level );
26312634 if (tmp & (MAY_BE_STRING |MAY_BE_ARRAY )) {
26322635 tmp |= MAY_BE_RC1 ;
26332636 }
0 commit comments