Skip to content

Commit 4568370

Browse files
committed
JIT: Fixed memory leak
1 parent 87069d3 commit 4568370

File tree

2 files changed

+44
-0
lines changed

2 files changed

+44
-0
lines changed

ext/opcache/jit/zend_jit_x86.dasc

Lines changed: 26 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2149,6 +2149,7 @@ static int zend_jit_undefined_function_stub(dasm_State **Dst)
21492149
static int zend_jit_negative_shift_stub(dasm_State **Dst)
21502150
{
21512151
|->negative_shift:
2152+
| mov RX, EX->opline
21522153
| UNDEF_OPLINE_RESULT_IF_USED
21532154
|.if X64
21542155
|.if WIN
@@ -2171,13 +2172,26 @@ static int zend_jit_negative_shift_stub(dasm_State **Dst)
21712172
| EXT_CALL zend_throw_error, r0
21722173
| add r4, 16
21732174
|.endif
2175+
| test byte OP:RX->op1_type, (IS_TMP_VAR|IS_VAR)
2176+
| je >9
2177+
| mov eax, dword OP:RX->op1.var
2178+
| add r0, FP
2179+
| ZVAL_PTR_DTOR ZEND_ADDR_MEM_ZVAL(ZREG_R0, 0), MAY_BE_ANY|MAY_BE_RC1|MAY_BE_RCN|MAY_BE_REF, 0, 0, NULL
2180+
|9:
2181+
| test byte OP:RX->op2_type, (IS_TMP_VAR|IS_VAR)
2182+
| je >9
2183+
| mov eax, dword OP:RX->op2.var
2184+
| add r0, FP
2185+
| ZVAL_PTR_DTOR ZEND_ADDR_MEM_ZVAL(ZREG_R0, 0), MAY_BE_ANY|MAY_BE_RC1|MAY_BE_RCN|MAY_BE_REF, 0, 0, NULL
2186+
|9:
21742187
| jmp ->exception_handler
21752188
return 1;
21762189
}
21772190

21782191
static int zend_jit_mod_by_zero_stub(dasm_State **Dst)
21792192
{
21802193
|->mod_by_zero:
2194+
| mov RX, EX->opline
21812195
| UNDEF_OPLINE_RESULT_IF_USED
21822196
|.if X64
21832197
|.if WIN
@@ -2200,6 +2214,18 @@ static int zend_jit_mod_by_zero_stub(dasm_State **Dst)
22002214
| EXT_CALL zend_throw_error, r0
22012215
| add r4, 16
22022216
|.endif
2217+
| test byte OP:RX->op1_type, (IS_TMP_VAR|IS_VAR)
2218+
| je >9
2219+
| mov eax, dword OP:RX->op1.var
2220+
| add r0, FP
2221+
| ZVAL_PTR_DTOR ZEND_ADDR_MEM_ZVAL(ZREG_R0, 0), MAY_BE_ANY|MAY_BE_RC1|MAY_BE_RCN|MAY_BE_REF, 0, 0, NULL
2222+
|9:
2223+
| test byte OP:RX->op2_type, (IS_TMP_VAR|IS_VAR)
2224+
| je >9
2225+
| mov eax, dword OP:RX->op2.var
2226+
| add r0, FP
2227+
| ZVAL_PTR_DTOR ZEND_ADDR_MEM_ZVAL(ZREG_R0, 0), MAY_BE_ANY|MAY_BE_RC1|MAY_BE_RCN|MAY_BE_REF, 0, 0, NULL
2228+
|9:
22032229
| jmp ->exception_handler
22042230
return 1;
22052231
}
Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,18 @@
1+
--TEST--
2+
JIT ASSIGN_OP: 005
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 = ["xy" => 0];
11+
$x = "";
12+
$a["x{$x}y"] %= 0;
13+
?>
14+
--EXPECTF--
15+
Fatal error: Uncaught DivisionByZeroError: Modulo by zero in %sassign_op_005.php:4
16+
Stack trace:
17+
#0 {main}
18+
thrown in %sassign_op_005.php on line 4

0 commit comments

Comments
 (0)