mirror of
https://github.com/php/php-src.git
synced 2025-08-16 05:58:45 +02:00
Convert warnings to ValueError
This commit is contained in:
parent
761e8c7707
commit
734932ecbb
3 changed files with 18 additions and 12 deletions
|
@ -313,13 +313,13 @@ static PHP_FUNCTION(json_decode)
|
|||
}
|
||||
|
||||
if (depth <= 0) {
|
||||
php_error_docref(NULL, E_WARNING, "Depth must be greater than zero");
|
||||
RETURN_NULL();
|
||||
zend_value_error("Depth must be greater than zero");
|
||||
return;
|
||||
}
|
||||
|
||||
if (depth > INT_MAX) {
|
||||
php_error_docref(NULL, E_WARNING, "Depth must be lower than %d", INT_MAX);
|
||||
RETURN_NULL();
|
||||
zend_value_error("Depth must be lower than %d", INT_MAX);
|
||||
return;
|
||||
}
|
||||
|
||||
/* For BC reasons, the bool $assoc overrides the long $options bit for PHP_JSON_OBJECT_AS_ARRAY */
|
||||
|
|
|
@ -6,9 +6,12 @@ Bug #72787 (json_decode reads out of bounds)
|
|||
--FILE--
|
||||
<?php
|
||||
|
||||
try {
|
||||
var_dump(json_decode('[]', false, 0x100000000));
|
||||
} catch (\ValueError $e) {
|
||||
echo $e->getMessage() . \PHP_EOL;
|
||||
}
|
||||
|
||||
?>
|
||||
--EXPECTF--
|
||||
Warning: json_decode(): Depth must be lower than %d in %s on line %d
|
||||
NULL
|
||||
Depth must be lower than %d
|
||||
|
|
|
@ -7,13 +7,16 @@ Test json_decode() function : error conditions
|
|||
echo "*** Testing json_decode() : error conditions ***\n";
|
||||
|
||||
echo "\n-- Testing json_decode() function with depth below 0 --\n";
|
||||
|
||||
try {
|
||||
var_dump(json_decode('"abc"', true, -1));
|
||||
} catch (\ValueError $e) {
|
||||
echo $e->getMessage() . \PHP_EOL;
|
||||
}
|
||||
|
||||
?>
|
||||
--EXPECTF--
|
||||
--EXPECT--
|
||||
*** Testing json_decode() : error conditions ***
|
||||
|
||||
-- Testing json_decode() function with depth below 0 --
|
||||
|
||||
Warning: json_decode(): Depth must be greater than zero in %s on line %d
|
||||
NULL
|
||||
Depth must be greater than zero
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue