Skip to content

Commit c163ff6

Browse files
committedOct 25, 2023
Fixed code generation for ASSIGN_DIM
Fixes oss-fuzz #63563
1 parent accc1e6 commit c163ff6

File tree

2 files changed

+34
-12
lines changed

2 files changed

+34
-12
lines changed
 

‎ext/opcache/jit/zend_jit_ir.c

+14-12
Original file line numberDiff line numberDiff line change
@@ -12799,19 +12799,21 @@ static int zend_jit_assign_dim(zend_jit_ctx *jit, const zend_op *opline, uint32_
1279912799
var_info |= MAY_BE_RC1;
1280012800
}
1280112801

12802-
ir_MERGE_N(found_inputs->count, found_inputs->refs);
12803-
ref = ir_PHI_N(IR_ADDR, found_values->count, found_values->refs);
12804-
var_addr = ZEND_ADDR_REF_ZVAL(ref);
12802+
if (found_inputs->count) {
12803+
ir_MERGE_N(found_inputs->count, found_inputs->refs);
12804+
ref = ir_PHI_N(IR_ADDR, found_values->count, found_values->refs);
12805+
var_addr = ZEND_ADDR_REF_ZVAL(ref);
1280512806

12806-
// JIT: value = zend_assign_to_variable(variable_ptr, value, OP_DATA_TYPE);
12807-
if (opline->op1_type == IS_VAR) {
12808-
ZEND_ASSERT(opline->result_type == IS_UNUSED);
12809-
if (!zend_jit_assign_to_variable_call(jit, opline, var_addr, var_addr, var_info, -1, (opline+1)->op1_type, op3_addr, val_info, res_addr, 0)) {
12810-
return 0;
12811-
}
12812-
} else {
12813-
if (!zend_jit_assign_to_variable(jit, opline, var_addr, var_addr, var_info, -1, (opline+1)->op1_type, op3_addr, val_info, res_addr, 0, 0)) {
12814-
return 0;
12807+
// JIT: value = zend_assign_to_variable(variable_ptr, value, OP_DATA_TYPE);
12808+
if (opline->op1_type == IS_VAR) {
12809+
ZEND_ASSERT(opline->result_type == IS_UNUSED);
12810+
if (!zend_jit_assign_to_variable_call(jit, opline, var_addr, var_addr, var_info, -1, (opline+1)->op1_type, op3_addr, val_info, res_addr, 0)) {
12811+
return 0;
12812+
}
12813+
} else {
12814+
if (!zend_jit_assign_to_variable(jit, opline, var_addr, var_addr, var_info, -1, (opline+1)->op1_type, op3_addr, val_info, res_addr, 0, 0)) {
12815+
return 0;
12816+
}
1281512817
}
1281612818
}
1281712819
}
+20
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,20 @@
1+
--TEST--
2+
JIT ASSIGN_DIM: 016
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() {
11+
$y[~$y] = 42;
12+
}
13+
@foo();
14+
?>
15+
--EXPECTF--
16+
Fatal error: Uncaught TypeError: Cannot perform bitwise not on null in %sassign_dim_016.php:3
17+
Stack trace:
18+
#0 %sassign_dim_016.php(5): foo()
19+
#1 {main}
20+
thrown in %sassign_dim_016.php on line 3

0 commit comments

Comments
 (0)