Skip to content

Commit 53df29b

Browse files
committed
Drop pi nodes for both old/new pred in replace_predecessor
We also need to drop pi nodes for new_pred here, as the pi node restriction for new_pred is not necessarily true for control coming from old_pred as well. Fixes oss-fuzz #40782.
1 parent e868ded commit 53df29b

File tree

2 files changed

+6
-1
lines changed

2 files changed

+6
-1
lines changed

Zend/tests/replace_pred_pi_node.phpt

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,11 @@ function test(bool $a, bool $b) {
77
if ($a && $byte > 0 && $b) {}
88
unknown($byte);
99
}
10+
function test2() {
11+
foreach (0 as $v) {
12+
$v ??= 0;
13+
}
14+
}
1015
?>
1116
===DONE===
1217
--EXPECT--

ext/opcache/Optimizer/dfa_pass.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -596,7 +596,7 @@ static void replace_predecessor(zend_ssa *ssa, int block_id, int old_pred, int n
596596
/* Also remove the corresponding phi node entries */
597597
for (phi = ssa->blocks[block_id].phis; phi; phi = phi->next) {
598598
if (phi->pi >= 0) {
599-
if (phi->pi == old_pred) {
599+
if (phi->pi == old_pred || phi->pi == new_pred) {
600600
zend_ssa_rename_var_uses(
601601
ssa, phi->ssa_var, phi->sources[0], /* update_types */ 0);
602602
zend_ssa_remove_phi(ssa, phi);

0 commit comments

Comments
 (0)