Skip to content

Commit 78a2fdd

Browse files
committed
Merge branch 'PHP-8.0' into PHP-8.1
* PHP-8.0: JIT: Fixed memory leak
2 parents 5fbba9b + 4b31cb3 commit 78a2fdd

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
@@ -7754,6 +7754,16 @@ int ZEND_FASTCALL zend_jit_trace_exit(uint32_t exit_num, zend_jit_registers_buf
77547754
}
77557755
}
77567756

7757+
if (repeat_last_opline) {
7758+
EX(opline) = t->exit_info[exit_num].opline - 1;
7759+
if ((EX(opline)->op1_type & (IS_VAR|IS_TMP_VAR))
7760+
&& !(t->exit_info[exit_num].flags & ZEND_JIT_EXIT_FREE_OP1)
7761+
&& EX(opline)->opcode != ZEND_FETCH_LIST_R) {
7762+
Z_TRY_ADDREF_P(EX_VAR(EX(opline)->op1.var));
7763+
}
7764+
return 1;
7765+
}
7766+
77577767
opline = t->exit_info[exit_num].opline;
77587768

77597769
if (opline) {
@@ -7818,11 +7828,6 @@ int ZEND_FASTCALL zend_jit_trace_exit(uint32_t exit_num, zend_jit_registers_buf
78187828
EX(opline)->lineno);
78197829
}
78207830

7821-
if (repeat_last_opline) {
7822-
EX(opline) = t->exit_info[exit_num].opline - 1;
7823-
return 1;
7824-
}
7825-
78267831
if (t->exit_info[exit_num].flags & ZEND_JIT_EXIT_TO_VM) {
78277832
if (zend_jit_trace_exit_is_bad(trace_num, exit_num)) {
78287833
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)