Skip to content

Commit 5460ffa

Browse files
committed
Add new test for array_fill() to cover the case when the parameter count is too large
1 parent f6c0c60 commit 5460ffa

File tree

1 file changed

+24
-0
lines changed

1 file changed

+24
-0
lines changed
Lines changed: 24 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,24 @@
1+
--TEST--
2+
Test array_fill() function : error conditions - count is too large
3+
--FILE--
4+
<?php
5+
echo "*** Testing array_fill() : error conditions - count is too large ***\n";
6+
7+
$intMax = 2147483647;
8+
9+
// calling array_fill() with 'count' larger than INT_MAX
10+
try {
11+
$array = array_fill(0, $intMax+1, 1);
12+
} catch (\ValueError $e) {
13+
echo $e->getMessage() . "\n";
14+
}
15+
16+
// calling array_fill() with 'count' equals to INT_MAX
17+
$array = array_fill(0, $intMax, 1);
18+
19+
?>
20+
--EXPECTF--
21+
*** Testing array_fill() : error conditions - count is too large ***
22+
array_fill(): Argument #2 ($count) is too large
23+
24+
Fatal error: Possible integer overflow in memory allocation (%d * %d + %d) in %s on line %d

0 commit comments

Comments
 (0)