Skip to content

Commit

Permalink
Save register before throwing undef var notice
Browse files Browse the repository at this point in the history
Otherwise we may clobber it while throwing the undef var notice.
This makes the implementation for assign_dim_op line up with
fetch_dim.
  • Loading branch information
nikic committed Sep 8, 2021
1 parent 0d0c9ac commit e22fb46
Show file tree
Hide file tree
Showing 2 changed files with 16 additions and 3 deletions.
6 changes: 3 additions & 3 deletions ext/opcache/jit/zend_jit_x86.dasc
Original file line number Diff line number Diff line change
Expand Up @@ -6454,6 +6454,9 @@ static int zend_jit_assign_dim_op(dasm_State **Dst, const zend_op *opline, uint3
| CMP_ZVAL_TYPE op1_addr, IS_FALSE
| jg >7
}
if (Z_REG(op1_addr) != ZREG_FP) {
| mov T1, Ra(Z_REG(op1_addr)) // save
}
if (op1_info & MAY_BE_UNDEF) {
if (op1_info & (MAY_BE_NULL|MAY_BE_FALSE)) {
| IF_NOT_ZVAL_TYPE op1_addr, IS_UNDEF, >1
Expand All @@ -6464,9 +6467,6 @@ static int zend_jit_assign_dim_op(dasm_State **Dst, const zend_op *opline, uint3
|1:
}
| // ZVAL_ARR(container, zend_new_array(8));
if (Z_REG(op1_addr) != ZREG_FP) {
| mov T1, Ra(Z_REG(op1_addr)) // save
}
| EXT_CALL _zend_new_array_0, r0
if (Z_REG(op1_addr) != ZREG_FP) {
| mov Ra(Z_REG(op1_addr)), T1 // restore
Expand Down
13 changes: 13 additions & 0 deletions ext/opcache/tests/jit/assign_dim_op_002.phpt
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
--TEST--
JIT ASSIGN_DIM_OP: Undefined variable
--INI--
opcache.enable=1
opcache.enable_cli=1
opcache.file_update_protection=0
opcache.jit_buffer_size=1M
--FILE--
<?php
$a[] &= 1;
?>
--EXPECTF--
Warning: Undefined variable $a in %s on line %d

0 comments on commit e22fb46

Please sign in to comment.