Skip to content

Commit 4b31cb3

Browse files
committed
JIT: Fixed memory leak
1 parent ee5711d commit 4b31cb3

File tree

2 files changed

+38
-5
lines changed

2 files changed

+38
-5
lines changed

ext/opcache/jit/zend_jit_trace.c

Lines changed: 10 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -7432,6 +7432,16 @@ int ZEND_FASTCALL zend_jit_trace_exit(uint32_t exit_num, zend_jit_registers_buf
74327432
}
74337433
}
74347434

7435+
if (repeat_last_opline) {
7436+
EX(opline) = t->exit_info[exit_num].opline - 1;
7437+
if ((EX(opline)->op1_type & (IS_VAR|IS_TMP_VAR))
7438+
&& !(t->exit_info[exit_num].flags & ZEND_JIT_EXIT_FREE_OP1)
7439+
&& EX(opline)->opcode != ZEND_FETCH_LIST_R) {
7440+
Z_TRY_ADDREF_P(EX_VAR(EX(opline)->op1.var));
7441+
}
7442+
return 1;
7443+
}
7444+
74357445
opline = t->exit_info[exit_num].opline;
74367446

74377447
if (opline) {
@@ -7496,11 +7506,6 @@ int ZEND_FASTCALL zend_jit_trace_exit(uint32_t exit_num, zend_jit_registers_buf
74967506
EX(opline)->lineno);
74977507
}
74987508

7499-
if (repeat_last_opline) {
7500-
EX(opline) = t->exit_info[exit_num].opline - 1;
7501-
return (EX(opline) == t->opline);
7502-
}
7503-
75047509
if (t->exit_info[exit_num].flags & ZEND_JIT_EXIT_TO_VM) {
75057510
if (zend_jit_trace_exit_is_bad(trace_num, exit_num)) {
75067511
zend_jit_blacklist_trace_exit(trace_num, exit_num);
Lines changed: 28 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,28 @@
1+
--TEST--
2+
JIT FETCH_DIM_R: 006
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 test() {
11+
$a['x'][1] = true;
12+
for ($i = 0; $i < 3; $i++) {
13+
var_dump($a['x'][0]);
14+
}
15+
}
16+
test();
17+
?>
18+
DONE
19+
--EXPECTF--
20+
Warning: Undefined array key 0 in %sfetch_dim_r_006.php on line 5
21+
NULL
22+
23+
Warning: Undefined array key 0 in %sfetch_dim_r_006.php on line 5
24+
NULL
25+
26+
Warning: Undefined array key 0 in %sfetch_dim_r_006.php on line 5
27+
NULL
28+
DONE

0 commit comments

Comments
 (0)