Fixed codegeneration for MATCH

Fixes oss-fuzz #63681
This commit is contained in:
Dmitry Stogov 2023-10-30 12:57:31 +03:00
parent e482785886
commit bd183a4069
3 changed files with 49 additions and 0 deletions

View file

@ -15572,6 +15572,16 @@ static int zend_jit_switch(zend_jit_ctx *jit, const zend_op *opline, const zend_
} ZEND_HASH_FOREACH_END();
_zend_jit_add_predecessor_ref(jit, default_b, jit->b, ref);
}
} else if (!(op1_info & MAY_BE_UNDEF)) {
if (next_opline) {
if (next_opline == default_opline) {
ir_END_list(continue_list);
} else {
jit_SIDE_EXIT(jit, ir_CONST_ADDR(default_label));
}
} else {
_zend_jit_add_predecessor_ref(jit, default_b, jit->b, ir_END());
}
}
if (op1_info & MAY_BE_UNDEF) {

View file

@ -0,0 +1,21 @@
--TEST--
JIT Match: 002 impossible input
--INI--
opcache.enable=1
opcache.enable_cli=1
opcache.file_update_protection=0
opcache.jit_buffer_size=1M
--FILE--
<?php
class C {
}
function foo(C $i) {
return match($i) {
1,2=>0,
default=>42
};
};
var_dump(foo(new C));
?>
--EXPECT--
int(42)

View file

@ -0,0 +1,18 @@
--TEST--
JIT Match: 003 impossible input
--INI--
opcache.enable=1
opcache.enable_cli=1
opcache.file_update_protection=0
opcache.jit_buffer_size=1M
--FILE--
<?php
function foo(C $i) {
match($i) {
1,2=>0
};
};
?>
DONE
--EXPECT--
DONE