1
0
mirror of https://github.com/php/php-src.git synced 2026-03-24 08:12:21 +01:00
Files
archived-php-src/ext/standard/tests/array/array_pad_too_large_padding.phpt
Niels 6ab503814d Make array_pad's $length warning less confusing (#10149)
Remove array_pad's arbitrary length restriction

The error message was wrong; it *is* possible to use a larger length.
Furthermore, there is an arbitrary restriction on the new array's
length.

Fix both by checking the length against HT_MAX_SIZE.
2023-01-14 12:15:56 +01:00

21 lines
463 B
PHP

--TEST--
array_pad() with too large padding should fail
--FILE--
<?php
function test($length) {
try {
var_dump(array_pad(array("", -1, 2.0), $length, 0));
} catch (\ValueError $e) {
echo $e->getMessage() . "\n";
}
}
test(PHP_INT_MIN);
test(PHP_INT_MAX);
?>
--EXPECT--
array_pad(): Argument #2 ($length) must not exceed the maximum allowed array size
array_pad(): Argument #2 ($length) must not exceed the maximum allowed array size