@@ -165,6 +165,8 @@ static inline uint32_t mask_for_type_check(uint32_t type) {
165
165
static int find_adjusted_tmp_var (const zend_op_array * op_array , uint32_t build_flags , zend_op * opline , uint32_t var_num , zend_long * adjustment ) /* {{{ */
166
166
{
167
167
zend_op * op = opline ;
168
+ zval * zv ;
169
+
168
170
while (op != op_array -> opcodes ) {
169
171
op -- ;
170
172
if (op -> result_type != IS_TMP_VAR || op -> result .var != var_num ) {
@@ -182,25 +184,28 @@ static int find_adjusted_tmp_var(const zend_op_array *op_array, uint32_t build_f
182
184
return EX_VAR_TO_NUM (op -> op1 .var );
183
185
}
184
186
} else if (op -> opcode == ZEND_ADD ) {
185
- if (op -> op1_type == IS_CV &&
186
- op -> op2_type == IS_CONST &&
187
- Z_TYPE_P (CRT_CONSTANT (op -> op2 )) == IS_LONG &&
188
- Z_LVAL_P (CRT_CONSTANT (op -> op2 )) != ZEND_LONG_MIN ) {
189
- * adjustment = - Z_LVAL_P (CRT_CONSTANT (op -> op2 ));
190
- return EX_VAR_TO_NUM (op -> op1 .var );
191
- } else if (op -> op2_type == IS_CV &&
192
- op -> op1_type == IS_CONST &&
193
- Z_TYPE_P (CRT_CONSTANT (op -> op1 )) == IS_LONG &&
194
- Z_LVAL_P (CRT_CONSTANT (op -> op1 )) != ZEND_LONG_MIN ) {
195
- * adjustment = - Z_LVAL_P (CRT_CONSTANT (op -> op1 ));
196
- return EX_VAR_TO_NUM (op -> op2 .var );
187
+ if (op -> op1_type == IS_CV && op -> op2_type == IS_CONST ) {
188
+ zv = CRT_CONSTANT (op -> op2 );
189
+ if (Z_TYPE_P (zv ) == IS_LONG
190
+ && Z_LVAL_P (zv ) != ZEND_LONG_MIN ) {
191
+ * adjustment = - Z_LVAL_P (zv );
192
+ return EX_VAR_TO_NUM (op -> op1 .var );
193
+ }
194
+ } else if (op -> op2_type == IS_CV && op -> op1_type == IS_CONST ) {
195
+ zv = CRT_CONSTANT (op -> op2 );
196
+ if (Z_TYPE_P (zv ) == IS_LONG
197
+ && Z_LVAL_P (zv ) != ZEND_LONG_MIN ) {
198
+ * adjustment = - Z_LVAL_P (zv );
199
+ return EX_VAR_TO_NUM (op -> op2 .var );
200
+ }
197
201
}
198
202
} else if (op -> opcode == ZEND_SUB ) {
199
- if (op -> op1_type == IS_CV &&
200
- op -> op2_type == IS_CONST &&
201
- Z_TYPE_P (CRT_CONSTANT (op -> op2 )) == IS_LONG ) {
202
- * adjustment = Z_LVAL_P (CRT_CONSTANT (op -> op2 ));
203
- return EX_VAR_TO_NUM (op -> op1 .var );
203
+ if (op -> op1_type == IS_CV && op -> op2_type == IS_CONST ) {
204
+ zv = CRT_CONSTANT (op -> op2 );
205
+ if (Z_TYPE_P (zv ) == IS_LONG ) {
206
+ * adjustment = Z_LVAL_P (zv );
207
+ return EX_VAR_TO_NUM (op -> op1 .var );
208
+ }
204
209
}
205
210
}
206
211
break ;
@@ -289,15 +294,18 @@ static void place_essa_pis(
289
294
}
290
295
} else if (var1 >= 0 && var2 < 0 ) {
291
296
zend_long add_val2 = 0 ;
292
- if ((opline - 1 )-> op2_type == IS_CONST &&
293
- Z_TYPE_P (CRT_CONSTANT ((opline - 1 )-> op2 )) == IS_LONG ) {
294
- add_val2 = Z_LVAL_P (CRT_CONSTANT ((opline - 1 )-> op2 ));
295
- } else if ((opline - 1 )-> op2_type == IS_CONST &&
296
- Z_TYPE_P (CRT_CONSTANT ((opline - 1 )-> op2 )) == IS_FALSE ) {
297
- add_val2 = 0 ;
298
- } else if ((opline - 1 )-> op2_type == IS_CONST &&
299
- Z_TYPE_P (CRT_CONSTANT ((opline - 1 )-> op2 )) == IS_TRUE ) {
300
- add_val2 = 1 ;
297
+ if ((opline - 1 )-> op2_type == IS_CONST ) {
298
+ zval * zv = CRT_CONSTANT ((opline - 1 )-> op2 );
299
+
300
+ if (Z_TYPE_P (zv ) == IS_LONG ) {
301
+ add_val2 = Z_LVAL_P (zv );
302
+ } else if (Z_TYPE_P (zv ) == IS_FALSE ) {
303
+ add_val2 = 0 ;
304
+ } else if (Z_TYPE_P (zv ) == IS_TRUE ) {
305
+ add_val2 = 1 ;
306
+ } else {
307
+ var1 = -1 ;
308
+ }
301
309
} else {
302
310
var1 = -1 ;
303
311
}
@@ -308,15 +316,17 @@ static void place_essa_pis(
308
316
}
309
317
} else if (var1 < 0 && var2 >= 0 ) {
310
318
zend_long add_val1 = 0 ;
311
- if ((opline - 1 )-> op1_type == IS_CONST &&
312
- Z_TYPE_P (CRT_CONSTANT ((opline - 1 )-> op1 )) == IS_LONG ) {
313
- add_val1 = Z_LVAL_P (CRT_CONSTANT ((opline - 1 )-> op1 ));
314
- } else if ((opline - 1 )-> op1_type == IS_CONST &&
315
- Z_TYPE_P (CRT_CONSTANT ((opline - 1 )-> op1 )) == IS_FALSE ) {
316
- add_val1 = 0 ;
317
- } else if ((opline - 1 )-> op1_type == IS_CONST &&
318
- Z_TYPE_P (CRT_CONSTANT ((opline - 1 )-> op1 )) == IS_TRUE ) {
319
- add_val1 = 1 ;
319
+ if ((opline - 1 )-> op1_type == IS_CONST ) {
320
+ zval * zv = CRT_CONSTANT ((opline - 1 )-> op1 );
321
+ if (Z_TYPE_P (zv ) == IS_LONG ) {
322
+ add_val1 = Z_LVAL_P (CRT_CONSTANT ((opline - 1 )-> op1 ));
323
+ } else if (Z_TYPE_P (zv ) == IS_FALSE ) {
324
+ add_val1 = 0 ;
325
+ } else if (Z_TYPE_P (zv ) == IS_TRUE ) {
326
+ add_val1 = 1 ;
327
+ } else {
328
+ var2 = -1 ;
329
+ }
320
330
} else {
321
331
var2 = -1 ;
322
332
}
0 commit comments