Skip to content

Commit 4df3281

Browse files
committed
Merge branch 'PHP-8.1'
* PHP-8.1: Fix leak with ASSIGN_OBJ on null
2 parents b976ad0 + b5242fa commit 4df3281

File tree

3 files changed

+43
-5
lines changed

3 files changed

+43
-5
lines changed

ext/opcache/jit/zend_jit_arm64.dasc

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -12923,12 +12923,12 @@ static int zend_jit_assign_obj_op(dasm_State **Dst,
1292312923
} else {
1292412924
| EXT_CALL zend_jit_invalid_property_assign, REG0
1292512925
}
12926+
may_throw = 1;
1292612927
if (((opline+1)->op1_type & (IS_VAR|IS_TMP_VAR))
1292712928
&& (val_info & (MAY_BE_REF|MAY_BE_STRING|MAY_BE_ARRAY|MAY_BE_OBJECT|MAY_BE_RESOURCE))) {
12928-
may_throw = 1;
1292912929
| b >8
1293012930
} else {
12931-
| b ->exception_handler
12931+
| b >9
1293212932
}
1293312933
|.code
1293412934
}
@@ -13296,7 +13296,7 @@ static int zend_jit_assign_obj(dasm_State **Dst,
1329613296
&& (val_info & (MAY_BE_REF|MAY_BE_STRING|MAY_BE_ARRAY|MAY_BE_OBJECT|MAY_BE_RESOURCE))) {
1329713297
| b >7
1329813298
} else {
13299-
| b ->exception_handler
13299+
| b >9
1330013300
}
1330113301
|.code
1330213302
}

ext/opcache/jit/zend_jit_x86.dasc

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -13667,12 +13667,13 @@ static int zend_jit_assign_obj_op(dasm_State **Dst,
1366713667
} else {
1366813668
| EXT_CALL zend_jit_invalid_property_assign, r0
1366913669
}
13670+
may_throw = 1;
1367013671
if (((opline+1)->op1_type & (IS_VAR|IS_TMP_VAR))
1367113672
&& (val_info & (MAY_BE_REF|MAY_BE_STRING|MAY_BE_ARRAY|MAY_BE_OBJECT|MAY_BE_RESOURCE))) {
1367213673
may_throw = 1;
1367313674
| jmp >8
1367413675
} else {
13675-
| jmp ->exception_handler
13676+
| jmp >9
1367613677
}
1367713678
|.code
1367813679
}
@@ -14081,7 +14082,7 @@ static int zend_jit_assign_obj(dasm_State **Dst,
1408114082
&& (val_info & (MAY_BE_REF|MAY_BE_STRING|MAY_BE_ARRAY|MAY_BE_OBJECT|MAY_BE_RESOURCE))) {
1408214083
| jmp >7
1408314084
} else {
14084-
| jmp ->exception_handler
14085+
| jmp >9
1408514086
}
1408614087
|.code
1408714088
}
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)