Skip to content

Commit e22fb46

Browse files
committed
Save register before throwing undef var notice
Otherwise we may clobber it while throwing the undef var notice. This makes the implementation for assign_dim_op line up with fetch_dim.
1 parent 0d0c9ac commit e22fb46

File tree

2 files changed

+16
-3
lines changed

2 files changed

+16
-3
lines changed

ext/opcache/jit/zend_jit_x86.dasc

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -6454,6 +6454,9 @@ static int zend_jit_assign_dim_op(dasm_State **Dst, const zend_op *opline, uint3
64546454
| CMP_ZVAL_TYPE op1_addr, IS_FALSE
64556455
| jg >7
64566456
}
6457+
if (Z_REG(op1_addr) != ZREG_FP) {
6458+
| mov T1, Ra(Z_REG(op1_addr)) // save
6459+
}
64576460
if (op1_info & MAY_BE_UNDEF) {
64586461
if (op1_info & (MAY_BE_NULL|MAY_BE_FALSE)) {
64596462
| IF_NOT_ZVAL_TYPE op1_addr, IS_UNDEF, >1
@@ -6464,9 +6467,6 @@ static int zend_jit_assign_dim_op(dasm_State **Dst, const zend_op *opline, uint3
64646467
|1:
64656468
}
64666469
| // ZVAL_ARR(container, zend_new_array(8));
6467-
if (Z_REG(op1_addr) != ZREG_FP) {
6468-
| mov T1, Ra(Z_REG(op1_addr)) // save
6469-
}
64706470
| EXT_CALL _zend_new_array_0, r0
64716471
if (Z_REG(op1_addr) != ZREG_FP) {
64726472
| mov Ra(Z_REG(op1_addr)), T1 // restore
Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,13 @@
1+
--TEST--
2+
JIT ASSIGN_DIM_OP: Undefined variable
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+
$a[] &= 1;
11+
?>
12+
--EXPECTF--
13+
Warning: Undefined variable $a in %s on line %d

0 commit comments

Comments
 (0)