File tree 4 files changed +73
-3
lines changed 4 files changed +73
-3
lines changed Original file line number Diff line number Diff line change @@ -7,9 +7,12 @@ class Test
7
7
static ?Test $ a = null ;
8
8
9
9
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 );
12
14
} else {
15
+ // Avoid cache slot, triggering write_property
13
16
var_dump (self ::$ a = $ this );
14
17
}
15
18
}
Original file line number Diff line number Diff line change 1
1
--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
3
3
--FILE--
4
4
<?php
5
5
Original file line number Diff line number Diff line change
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
Original file line number Diff line number Diff line change
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
You can’t perform that action at this time.
0 commit comments