Skip to content

Commit 2600712

Browse files
committed
More tests
1 parent fcf4ab3 commit 2600712

File tree

4 files changed

+73
-3
lines changed

4 files changed

+73
-3
lines changed

Zend/tests/gh10168_3.phpt

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -7,9 +7,12 @@ class Test
77
static ?Test $a = null;
88

99
public function __construct() {
10-
if (self::$a === null) {
11-
var_dump(self::$a = &$this);
10+
static $i = 0;
11+
$i++;
12+
if ($i === 1) {
13+
var_dump(self::$a = $this);
1214
} else {
15+
// Avoid cache slot, triggering write_property
1316
var_dump(self::$a = $this);
1417
}
1518
}

Zend/tests/gh10168_4.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 prop
33
--FILE--
44
<?php
55

Zend/tests/gh10168_7.phpt

Lines changed: 31 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,31 @@
1+
--TEST--
2+
GH-10168 (heap-buffer-overflow at zval_undefined_cv): assign typed static prop by ref
3+
--XFAIL--
4+
--FILE--
5+
<?php
6+
7+
class Test
8+
{
9+
static ?Test $a = null;
10+
11+
public function __construct() {
12+
var_dump(self::$a = &$this);
13+
}
14+
15+
function __destruct() {
16+
var_dump(self::$a);
17+
self::$a = null;
18+
}
19+
}
20+
new Test();
21+
new Test();
22+
23+
?>
24+
--EXPECT--
25+
object(Test)#1 (0) {
26+
}
27+
object(Test)#2 (0) {
28+
}
29+
object(Test)#2 (0) {
30+
}
31+
NULL

Zend/tests/gh10168_8.phpt

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

0 commit comments

Comments
 (0)