Description
Potential problem
Hi!
I was analyzing the source code and came across a potential issue in Zend/Optimizer/sccp.c.
In the following line:
if (ct_eval_fetch_obj(&tmp, op1, op2) == SUCCESS) {
op2 is obtained using get_op2_value(). If opline->op2_type != IS_CONST and ssa_op->op2_use == -1, this function may return NULL.
At the same time, the SKIP_IF_TOP(op2) macro appears to check for the IS_TOP(op2) state, but does not explicitly check whether op2 is NULL. As a result, it seems possible that ct_eval_fetch_obj() could be called with op2 == NULL.
Inside ct_eval_fetch_obj(), op2 is passed to fetch_obj_prop(), where it appears to be dereferenced without a prior NULL check.
Could you please check whether it is guaranteed that op2 is always non-NULL at this point?
I would appreciate it if you could verify this scenario.
Found with SVACE
PHP Version
Operating System
Ubuntu 24.04
Description
Potential problem
Hi!
I was analyzing the source code and came across a potential issue in Zend/Optimizer/sccp.c.
In the following line:
if (ct_eval_fetch_obj(&tmp, op1, op2) == SUCCESS) {
op2 is obtained using get_op2_value(). If opline->op2_type != IS_CONST and ssa_op->op2_use == -1, this function may return NULL.
At the same time, the SKIP_IF_TOP(op2) macro appears to check for the IS_TOP(op2) state, but does not explicitly check whether op2 is NULL. As a result, it seems possible that ct_eval_fetch_obj() could be called with op2 == NULL.
Inside ct_eval_fetch_obj(), op2 is passed to fetch_obj_prop(), where it appears to be dereferenced without a prior NULL check.
Could you please check whether it is guaranteed that op2 is always non-NULL at this point?
I would appreciate it if you could verify this scenario.
Found with SVACE
PHP Version
Operating System
Ubuntu 24.04