Skip to content

Commit f381079

Browse files
committed
Check exception after QM_ASSIGN of undef var
While most other exceptions aren't possible when QM_ASSIGN is used instead of ASSIGN, we still have to watch out for an undef var notice being promoted to an exception.
1 parent 17d6efc commit f381079

File tree

2 files changed

+25
-0
lines changed

2 files changed

+25
-0
lines changed

ext/opcache/jit/zend_jit_x86.dasc

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -8790,6 +8790,9 @@ static int zend_jit_qm_assign(dasm_State **Dst, const zend_op *opline, uint32_t
87908790
if (!zend_jit_store_var_if_necessary(Dst, opline->result.var, res_addr, res_info)) {
87918791
return 0;
87928792
}
8793+
if (op1_info & MAY_BE_UNDEF) {
8794+
zend_jit_check_exception(Dst);
8795+
}
87938796
return 1;
87948797
}
87958798

Lines changed: 22 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,22 @@
1+
--TEST--
2+
QM_ASSIGN of undef var may throw exception
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+
set_error_handler(function($_, $m) { throw new Exception($m); });
11+
function test() {
12+
$a = $b;
13+
X;
14+
}
15+
try {
16+
test();
17+
} catch (Exception $e) {
18+
echo $e->getMessage(), "\n";
19+
}
20+
?>
21+
--EXPECT--
22+
Undefined variable $b

0 commit comments

Comments
 (0)