Skip to content

Commit 97b5eee

Browse files
committed
Fix leak with ASSIGN_OBJ on null
We still need to free op1 in this case. Fixes oss-fuzz 5782176231194624 (part of #38542).
1 parent 2f798d9 commit 97b5eee

File tree

2 files changed

+40
-2
lines changed

2 files changed

+40
-2
lines changed

ext/opcache/jit/zend_jit_x86.dasc

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -13731,11 +13731,12 @@ static int zend_jit_assign_obj_op(dasm_State **Dst,
1373113731
} else {
1373213732
| EXT_CALL zend_jit_invalid_property_assign, r0
1373313733
}
13734+
may_throw = 1;
1373413735
if (((opline+1)->op1_type & (IS_VAR|IS_TMP_VAR))
1373513736
&& (val_info & (MAY_BE_REF|MAY_BE_STRING|MAY_BE_ARRAY|MAY_BE_OBJECT|MAY_BE_RESOURCE))) {
1373613737
| jmp >8
1373713738
} else {
13738-
| jmp ->exception_handler
13739+
| jmp >9
1373913740
}
1374013741
|.code
1374113742
}
@@ -14067,7 +14068,7 @@ static int zend_jit_assign_obj(dasm_State **Dst,
1406714068
&& (val_info & (MAY_BE_REF|MAY_BE_STRING|MAY_BE_ARRAY|MAY_BE_OBJECT|MAY_BE_RESOURCE))) {
1406814069
| jmp >7
1406914070
} else {
14070-
| jmp ->exception_handler
14071+
| jmp >9
1407114072
}
1407214073
|.code
1407314074
}
Lines changed: 37 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,37 @@
1+
--TEST--
2+
ASSIGN_OBJ on null reference returned from __get()
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+
class Test {
11+
public $prop;
12+
public function &__get($name) {
13+
return $this->prop;
14+
}
15+
}
16+
function test() {
17+
$obj = new Test;
18+
$obj->x->y = 1;
19+
}
20+
function test2() {
21+
$obj = new Test;
22+
$obj->x->y += 1;
23+
}
24+
try {
25+
test();
26+
} catch (Error $e) {
27+
echo $e->getMessage(), "\n";
28+
}
29+
try {
30+
test2();
31+
} catch (Error $e) {
32+
echo $e->getMessage(), "\n";
33+
}
34+
?>
35+
--EXPECT--
36+
Attempt to assign property "y" on null
37+
Attempt to assign property "y" on null

0 commit comments

Comments
 (0)