1
0
mirror of https://github.com/php/php-src.git synced 2026-03-24 00:02:20 +01:00

Fixed compilation of match with undefined input

Fixes oss-fuzz #63542
This commit is contained in:
Dmitry Stogov
2023-10-24 22:12:53 +03:00
parent f9a9008fea
commit 23e4e3b18b
2 changed files with 29 additions and 3 deletions

View File

@@ -15549,9 +15549,13 @@ static int zend_jit_switch(zend_jit_ctx *jit, const zend_op *opline, const zend_
ir_MERGE_list(continue_list);
} else {
if (default_input_list) {
ZEND_ASSERT(jit->ctx.ir_base[ref].op == IR_SWITCH);
ZEND_ASSERT(jit->ctx.ir_base[ref].op3 == IR_UNUSED);
jit->ctx.ir_base[ref].op3 = default_input_list;
if (jit->ctx.ir_base[ref].op == IR_SWITCH) {
ZEND_ASSERT(jit->ctx.ir_base[ref].op3 == IR_UNUSED);
jit->ctx.ir_base[ref].op3 = default_input_list;
} else {
ir_MERGE_list(default_input_list);
_zend_jit_add_predecessor_ref(jit, default_b, jit->b, ir_END());
}
}
jit->b = -1;
}

View File

@@ -0,0 +1,22 @@
--TEST--
Match with undefined input
--INI--
opcache.enable=1
opcache.enable_cli=1
opcache.file_update_protection=0
opcache.jit_buffer_size=1M
--FILE--
<?php
function foo() {
return match($y){1,6=>0};
}
foo();
?>
--EXPECTF--
Warning: Undefined variable $y in %smatch_001.php on line 3
Fatal error: Uncaught UnhandledMatchError: Unhandled match case NULL in %smatch_001.php:3
Stack trace:
#0 %smatch_001.php(5): foo()
#1 {main}
thrown in %smatch_001.php on line 3