summaryrefslogtreecommitdiff
path: root/ext/standard/tests/array/bug28974.phpt
blob: fb272e1d744dc9bb8c54e521b52690c4318088f3 (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
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
--TEST--
Bug #28974 array_(p)slice() treats large lengths incorrectly - overflow
--FILE--
<?php
$a = $b = $c = array(0,1,2,3,4,5);
print_r($a);
// this is ok:
print_r(array_slice($a,2,2147483645));

// this is wrong:
print_r(array_slice($a,2,2147483646));
echo 'print_r(array_splice($a,2,1));'."\n";
print_r(array_splice($a,2,1));
echo "\$a is :";
print_r($a);
echo 'print_r(array_splice($b,2,2147483645));'."\n";
print_r(array_splice($b,2,2147483645));
echo "\$b is :";
print_r($b);

// this is wrong:
echo 'print_r(array_splice($c,2,2147483646));'."\n";
print_r(array_splice($c,2,2147483646));
echo "\$c is :";
print_r($c);
?>
--EXPECT--
Array
(
    [0] => 0
    [1] => 1
    [2] => 2
    [3] => 3
    [4] => 4
    [5] => 5
)
Array
(
    [0] => 2
    [1] => 3
    [2] => 4
    [3] => 5
)
Array
(
    [0] => 2
    [1] => 3
    [2] => 4
    [3] => 5
)
print_r(array_splice($a,2,1));
Array
(
    [0] => 2
)
$a is :Array
(
    [0] => 0
    [1] => 1
    [2] => 3
    [3] => 4
    [4] => 5
)
print_r(array_splice($b,2,2147483645));
Array
(
    [0] => 2
    [1] => 3
    [2] => 4
    [3] => 5
)
$b is :Array
(
    [0] => 0
    [1] => 1
)
print_r(array_splice($c,2,2147483646));
Array
(
    [0] => 2
    [1] => 3
    [2] => 4
    [3] => 5
)
$c is :Array
(
    [0] => 0
    [1] => 1
)