Skip to content

Commit cbe9d67

Browse files
committed
Add tests for GH-17151
1 parent f044174 commit cbe9d67

File tree

3 files changed

+76
-0
lines changed

3 files changed

+76
-0
lines changed

ext/opcache/tests/jit/gh17151_1.phpt

Lines changed: 22 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,22 @@
1+
--TEST--
2+
GH-17151: ZEND_FETCH_OBJ_R may modify RC of op1
3+
--FILE--
4+
<?php
5+
6+
class C {
7+
public function __get($name) {
8+
return $this;
9+
}
10+
}
11+
12+
function test() {
13+
$x = (new C)->bar;
14+
var_dump($x);
15+
}
16+
17+
test();
18+
19+
?>
20+
--EXPECTF--
21+
object(C)#%d (0) {
22+
}

ext/opcache/tests/jit/gh17151_2.phpt

Lines changed: 29 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,29 @@
1+
--TEST--
2+
GH-17151: ZEND_FETCH_OBJ_R may modify RC of op1
3+
--FILE--
4+
<?php
5+
6+
class C {
7+
public static $prop;
8+
9+
public function __get($name) {
10+
C::$prop = null;
11+
}
12+
13+
public function __destruct() {
14+
echo __METHOD__, "\n";
15+
}
16+
}
17+
18+
function test() {
19+
C::$prop = new C();
20+
C::$prop->bar;
21+
}
22+
23+
test();
24+
echo "Done\n";
25+
26+
?>
27+
--EXPECT--
28+
C::__destruct
29+
Done

ext/opcache/tests/jit/gh17151_3.phpt

Lines changed: 25 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,25 @@
1+
--TEST--
2+
GH-17151: Method calls may modify RC of ZEND_INIT_METHOD_CALL op1
3+
--FILE--
4+
<?php
5+
6+
class C {
7+
public static $prop;
8+
9+
public function storeThis() {
10+
self::$prop = $this;
11+
}
12+
}
13+
14+
function test() {
15+
$c = new C();
16+
$c->storeThis();
17+
$c = null;
18+
}
19+
20+
test();
21+
22+
?>
23+
===DONE===
24+
--EXPECT--
25+
===DONE===

0 commit comments

Comments
 (0)