Skip to content

Commit

Permalink
JIT: Fix ASSIGN_DIM_OP with undefined variable and index and user err…
Browse files Browse the repository at this point in the history
…or handler, throwing an exception

Fixes oss-fuzz #39422
  • Loading branch information
dstogov committed Dec 2, 2021
1 parent 94286cd commit 2fde308
Show file tree
Hide file tree
Showing 2 changed files with 35 additions and 0 deletions.
3 changes: 3 additions & 0 deletions ext/opcache/jit/zend_jit_helpers.c
Original file line number Diff line number Diff line change
Expand Up @@ -690,6 +690,9 @@ static zval* ZEND_FASTCALL zend_jit_fetch_dim_rw_helper(zend_array *ht, zval *di
case IS_UNDEF:
execute_data = EG(current_execute_data);
opline = EX(opline);
if (UNEXPECTED(opline->opcode == ZEND_HANDLE_EXCEPTION)) {
opline = EG(opline_before_exception);
}
if (!zend_jit_undefined_op_helper_write(ht, opline->op2.var)) {
if (opline->result_type & (IS_VAR | IS_TMP_VAR)) {
if (EG(exception)) {
Expand Down
32 changes: 32 additions & 0 deletions ext/opcache/tests/jit/assign_dim_op_005.phpt
Original file line number Diff line number Diff line change
@@ -0,0 +1,32 @@
--TEST--
JIT ASSIGN_DIM_OP: Undefined variable and index with exception
--INI--
opcache.enable=1
opcache.enable_cli=1
opcache.file_update_protection=0
opcache.jit_buffer_size=1M
--FILE--
<?php
set_error_handler(function($_, $m){
throw new Exception($m);
});
function test1() {
$res = $a[$undef] = null;
}
function test2() {
$res = $a[$undef] += 1;
}
try {
test1();
} catch (Exception $e) {
echo $e->getMessage(), "\n";
}
try {
test2();
} catch (Exception $e) {
echo $e->getMessage(), "\n";
}
?>
--EXPECT--
Undefined variable $undef
Undefined variable $a

0 comments on commit 2fde308

Please sign in to comment.