-
Notifications
You must be signed in to change notification settings - Fork 7.7k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Add new test for array_fill() to cover the case when the parameter co…
…unt is too large
- Loading branch information
Showing
1 changed file
with
26 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,26 @@ | ||
--TEST-- | ||
Test array_fill() function : error conditions - count is too large | ||
--SKIPIF-- | ||
<?php if (PHP_INT_SIZE != 8) die("skip this test is for 64bit platform only"); ?> | ||
--FILE-- | ||
<?php | ||
echo "*** Testing array_fill() : error conditions ***\n"; | ||
|
||
$intMax = 2147483647; | ||
|
||
// calling array_fill() with 'count' larger than INT_MAX | ||
try { | ||
$array = array_fill(0, $intMax+1, 1); | ||
} catch (\ValueError $e) { | ||
echo $e->getMessage() . "\n"; | ||
} | ||
|
||
// calling array_fill() with 'count' equals to INT_MAX | ||
$array = array_fill(0, $intMax, 1); | ||
|
||
?> | ||
--EXPECTF-- | ||
*** Testing array_fill() : error conditions *** | ||
array_fill(): Argument #2 ($count) is too large | ||
|
||
Fatal error: Possible integer overflow in memory allocation (%d * %d + %d) in %s on line %d |