Skip to content

Potential NULL dereference in sccp.c #23796

Description

@Ti-Mis

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

PHP 8.3.24

Operating System

Ubuntu 24.04

Activity

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions