Skip to content

Commit fcf4ab3

Browse files
committed
Add test demonstrating write_property problem
1 parent 45c457d commit fcf4ab3

File tree

4 files changed

+43
-10
lines changed

4 files changed

+43
-10
lines changed

Zend/tests/gh10168_3.phpt

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
--TEST--
2-
GH-10168 (heap-buffer-overflow at zval_undefined_cv): assign typed prop
2+
GH-10168 (heap-buffer-overflow at zval_undefined_cv): assign typed static prop
33
--FILE--
44
<?php
55
class Test

Zend/tests/gh10168_4.phpt

Lines changed: 1 addition & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -11,16 +11,9 @@ $box = new Box();
1111

1212
class Test
1313
{
14-
static ?Test $a = null;
15-
1614
public function __construct() {
1715
global $box;
18-
19-
if (self::$a === null) {
20-
var_dump($box->storage = $this);
21-
} else {
22-
var_dump($box->storage = $this);
23-
}
16+
var_dump($box->storage = $this);
2417
}
2518

2619
function __destruct() {

Zend/tests/gh10168_5.phpt

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
--TEST--
2-
GH-10168 (heap-buffer-overflow at zval_undefined_cv): assign typed prop
2+
GH-10168 (heap-buffer-overflow at zval_undefined_cv): allocated assignment in destructor
33
--FILE--
44
<?php
55

Zend/tests/gh10168_6.phpt

Lines changed: 40 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,40 @@
1+
--TEST--
2+
GH-10168 (heap-buffer-overflow at zval_undefined_cv): assign typed prop without cache slot
3+
--XFAIL--
4+
--FILE--
5+
<?php
6+
7+
class Box {
8+
public $storage;
9+
}
10+
11+
$box = new Box();
12+
13+
class Test
14+
{
15+
public function __construct() {
16+
static $i = 0;
17+
$i++;
18+
global $box;
19+
if ($i === 1) {
20+
var_dump($box->storage = $this);
21+
} else {
22+
// Avoid cache slot, triggering write_property
23+
var_dump($box->storage = $this);
24+
}
25+
}
26+
27+
function __destruct() {
28+
global $box;
29+
$box->storage = null;
30+
}
31+
}
32+
new Test();
33+
new Test();
34+
35+
?>
36+
--EXPECT--
37+
object(Test)#2 (0) {
38+
}
39+
object(Test)#3 (0) {
40+
}

0 commit comments

Comments
 (0)