summaryrefslogtreecommitdiff
path: root/ext/standard/tests/strings/bug55871.phpt
blob: 249d1bd3a326f50184147f757c5630cd86145f65 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
--TEST--
Bug #55871 (Interruption in substr_replace()) (PHP7)
--FILE--
<?php
class test1 {
	public function __toString() {
		preg_match('//', '', $GLOBALS['my_var']);
		return '';
	}
}

class test2 {
        public function __toString() {
		$GLOBALS['my_var'] += 0x08048000;
                return '';
        }
}

class test3 {
        public function __toString() {                
                $GLOBALS['my_var'] .= "AAAAAAAA";
                return '';
        }
}

$my_var = str_repeat('A', 40);
$out = substr_replace(array(&$my_var), array(new test1), 40, 0);
var_dump($out, $my_var);
$my_var = str_repeat('A', 40);
$out = substr_replace(array(&$my_var), array(new test2), 40, 0);
var_dump($out, $my_var);
$my_var = str_repeat('A', 40);
$out = substr_replace(array(&$my_var), array(new test3), 40, 0);
var_dump($out, $my_var);
--EXPECTF--
array(1) {
  [0]=>
  string(40) "AAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA"
}
array(1) {
  [0]=>
  string(0) ""
}
array(1) {
  [0]=>
  string(40) "AAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA"
}
int(134512640)
array(1) {
  [0]=>
  string(40) "AAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA"
}
string(48) "AAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA"