Skip to content

Commit 44b86ae

Browse files
committed
Fix memory leak
Fixes oss-fuzz #49272
1 parent 3962f00 commit 44b86ae

File tree

2 files changed

+22
-0
lines changed

2 files changed

+22
-0
lines changed

ext/opcache/jit/zend_jit_x86.dasc

+4
Original file line numberDiff line numberDiff line change
@@ -5335,6 +5335,10 @@ static int zend_jit_long_math_helper(dasm_State **Dst,
53355335
|.if not(X64)
53365336
| add r4, 12
53375337
|.endif
5338+
if (op1_addr == res_addr && (op2_info & MAY_BE_RCN)) {
5339+
/* compound assignment may decrement "op2" refcount */
5340+
op2_info |= MAY_BE_RC1;
5341+
}
53385342
| FREE_OP op1_type, op1, op1_info, 0, opline
53395343
| FREE_OP op2_type, op2, op2_info, 0, opline
53405344
if (may_throw) {

ext/opcache/tests/jit/and_002.phpt

+18
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,18 @@
1+
--TEST--
2+
JIT BW_AND: 002 (memory leak)
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 t($a) {
11+
for($i = 0; $i < 2; $i++)
12+
$a &= $a = $a;
13+
}
14+
t("");
15+
?>
16+
DONE
17+
--EXPECTF--
18+
DONE

0 commit comments

Comments
 (0)