Merge branch 'PHP-8.1'

* PHP-8.1:
  Fix memory leak
This commit is contained in:
Dmitry Stogov 2022-07-25 12:08:09 +03:00
commit 4227fddf4d
3 changed files with 26 additions and 0 deletions

View File

@ -4928,6 +4928,10 @@ static int zend_jit_long_math_helper(dasm_State **Dst,
} else {
ZEND_UNREACHABLE();
}
if (op1_addr == res_addr && (op2_info & MAY_BE_RCN)) {
/* compound assignment may decrement "op2" refcount */
op2_info |= MAY_BE_RC1;
}
| FREE_OP op1_type, op1, op1_info, 0, NULL, ZREG_TMP1, ZREG_TMP2
| FREE_OP op2_type, op2, op2_info, 0, NULL, ZREG_TMP1, ZREG_TMP2
if (may_throw) {

View File

@ -5423,6 +5423,10 @@ static int zend_jit_long_math_helper(dasm_State **Dst,
|.if not(X64)
| add r4, 12
|.endif
if (op1_addr == res_addr && (op2_info & MAY_BE_RCN)) {
/* compound assignment may decrement "op2" refcount */
op2_info |= MAY_BE_RC1;
}
| FREE_OP op1_type, op1, op1_info, 0, NULL
| FREE_OP op2_type, op2, op2_info, 0, NULL
if (may_throw) {

View File

@ -0,0 +1,18 @@
--TEST--
JIT BW_AND: 002 (memory leak)
--INI--
opcache.enable=1
opcache.enable_cli=1
opcache.file_update_protection=0
opcache.jit_buffer_size=1M
--FILE--
<?php
function t($a) {
for($i = 0; $i < 2; $i++)
$a &= $a = $a;
}
t("");
?>
DONE
--EXPECTF--
DONE