Skip to content

Conversation

@ndossche
Copy link
Member

@ndossche ndossche commented Dec 19, 2025

In this example, the SCCP pass causes the JMPNZ instruction to be the last instruction in the op_array, and always jump to itself. In those cases i + 1 in the CFG builder can point to outside the op_array because i is already the last opline.
To solve this we need to check against the end and prevent setting the successor out of bounds.

The proposed solution is not really pretty. Ideally SCCP can replace the JMPNZ opcode with a JMP opcode, but that's more risky to commit to a stable branch.

Some (conditional) jump instructions can be the last one in the
op_array, because they can jump to themselves. In those cases `i + 1` in
the CFG builder can point to outside the op_array because `i` is already
the last opline.
To solve this we need to check against the end and prevent setting the
successor out of bounds.
@ndossche ndossche linked an issue Dec 19, 2025 that may be closed by this pull request
@ndossche ndossche marked this pull request as ready for review December 20, 2025 10:18
@ndossche ndossche requested a review from dstogov as a code owner December 20, 2025 10:18
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

heap buffer overflow in optimizer

1 participant