Skip to content

Commit bd183a4

Browse files
committedOct 30, 2023
Fixed codegeneration for MATCH
Fixes oss-fuzz #63681
1 parent e482785 commit bd183a4

File tree

3 files changed

+49
-0
lines changed

3 files changed

+49
-0
lines changed
 

‎ext/opcache/jit/zend_jit_ir.c

+10
Original file line numberDiff line numberDiff line change
@@ -15572,6 +15572,16 @@ static int zend_jit_switch(zend_jit_ctx *jit, const zend_op *opline, const zend_
1557215572
} ZEND_HASH_FOREACH_END();
1557315573
_zend_jit_add_predecessor_ref(jit, default_b, jit->b, ref);
1557415574
}
15575+
} else if (!(op1_info & MAY_BE_UNDEF)) {
15576+
if (next_opline) {
15577+
if (next_opline == default_opline) {
15578+
ir_END_list(continue_list);
15579+
} else {
15580+
jit_SIDE_EXIT(jit, ir_CONST_ADDR(default_label));
15581+
}
15582+
} else {
15583+
_zend_jit_add_predecessor_ref(jit, default_b, jit->b, ir_END());
15584+
}
1557515585
}
1557615586

1557715587
if (op1_info & MAY_BE_UNDEF) {

‎ext/opcache/tests/jit/match_002.phpt

+21
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,21 @@
1+
--TEST--
2+
JIT Match: 002 impossible input
3+
--INI--
4+
opcache.enable=1
5+
opcache.enable_cli=1
6+
opcache.file_update_protection=0
7+
opcache.jit_buffer_size=1M
8+
--FILE--
9+
<?php
10+
class C {
11+
}
12+
function foo(C $i) {
13+
return match($i) {
14+
1,2=>0,
15+
default=>42
16+
};
17+
};
18+
var_dump(foo(new C));
19+
?>
20+
--EXPECT--
21+
int(42)

‎ext/opcache/tests/jit/match_003.phpt

+18
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,18 @@
1+
--TEST--
2+
JIT Match: 003 impossible input
3+
--INI--
4+
opcache.enable=1
5+
opcache.enable_cli=1
6+
opcache.file_update_protection=0
7+
opcache.jit_buffer_size=1M
8+
--FILE--
9+
<?php
10+
function foo(C $i) {
11+
match($i) {
12+
1,2=>0
13+
};
14+
};
15+
?>
16+
DONE
17+
--EXPECT--
18+
DONE

0 commit comments

Comments
 (0)
Please sign in to comment.