Skip to content

Commit 38626db

Browse files
committed
JIT: Fixed memory leak
1 parent 23a6075 commit 38626db

File tree

2 files changed

+22
-1
lines changed

2 files changed

+22
-1
lines changed

ext/opcache/jit/zend_jit_x86.dasc

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5364,6 +5364,7 @@ static int zend_jit_fetch_dimension_address_inner(dasm_State **Dst, const zend_o
53645364
if (op2_info & MAY_BE_LONG) {
53655365
zend_bool op2_loaded = 0;
53665366
zend_bool packed_loaded = 0;
5367+
zend_bool bad_packed_key = 0;
53675368

53685369
if (op2_info & ((MAY_BE_ANY|MAY_BE_UNDEF) - MAY_BE_LONG)) {
53695370
| // if (EXPECTED(Z_TYPE_P(dim) == IS_LONG))
@@ -5396,6 +5397,8 @@ static int zend_jit_fetch_dimension_address_inner(dasm_State **Dst, const zend_o
53965397
val = Z_LVAL_P(Z_ZV(op2_addr));
53975398
if (val >= 0 && val < HT_MAX_SIZE) {
53985399
packed_loaded = 1;
5400+
} else {
5401+
bad_packed_key = 1;
53995402
}
54005403
} else {
54015404
if (!op2_loaded) {
@@ -5594,7 +5597,7 @@ static int zend_jit_fetch_dimension_address_inner(dasm_State **Dst, const zend_o
55945597
if (packed_loaded) {
55955598
| IF_NOT_Z_TYPE r0, IS_UNDEF, >8
55965599
}
5597-
if (!(op1_info & MAY_BE_ARRAY_KEY_LONG) || packed_loaded) {
5600+
if (!(op1_info & MAY_BE_ARRAY_KEY_LONG) || packed_loaded || bad_packed_key) {
55985601
|2:
55995602
| //retval = zend_hash_index_add_new(ht, hval, &EG(uninitialized_zval));
56005603
if (!op2_loaded) {
Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,18 @@
1+
--TEST--
2+
JIT FETCH_DIM_W: 001
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 &foo() {
11+
$a = array(1);
12+
return $a[-1];
13+
}
14+
15+
var_dump(foo());
16+
?>
17+
--EXPECT--
18+
NULL

0 commit comments

Comments
 (0)