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) {
|
if (depth <= 0) {
|
||||||
php_error_docref(NULL, E_WARNING, "Depth must be greater than zero");
|
zend_value_error("Depth must be greater than zero");
|
||||||
RETURN_NULL();
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (depth > INT_MAX) {
|
if (depth > INT_MAX) {
|
||||||
php_error_docref(NULL, E_WARNING, "Depth must be lower than %d", INT_MAX);
|
zend_value_error("Depth must be lower than %d", INT_MAX);
|
||||||
RETURN_NULL();
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
/* For BC reasons, the bool $assoc overrides the long $options bit for PHP_JSON_OBJECT_AS_ARRAY */
|
/* 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--
|
--FILE--
|
||||||
<?php
|
<?php
|
||||||
|
|
||||||
var_dump(json_decode('[]', false, 0x100000000));
|
try {
|
||||||
|
var_dump(json_decode('[]', false, 0x100000000));
|
||||||
|
} catch (\ValueError $e) {
|
||||||
|
echo $e->getMessage() . \PHP_EOL;
|
||||||
|
}
|
||||||
|
|
||||||
?>
|
?>
|
||||||
--EXPECTF--
|
--EXPECTF--
|
||||||
Warning: json_decode(): Depth must be lower than %d in %s on line %d
|
Depth must be lower than %d
|
||||||
NULL
|
|
||||||
|
|
|
@ -7,13 +7,16 @@ Test json_decode() function : error conditions
|
||||||
echo "*** Testing json_decode() : error conditions ***\n";
|
echo "*** Testing json_decode() : error conditions ***\n";
|
||||||
|
|
||||||
echo "\n-- Testing json_decode() function with depth below 0 --\n";
|
echo "\n-- Testing json_decode() function with depth below 0 --\n";
|
||||||
var_dump(json_decode('"abc"', true, -1));
|
|
||||||
|
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() : error conditions ***
|
||||||
|
|
||||||
-- Testing json_decode() function with depth below 0 --
|
-- Testing json_decode() function with depth below 0 --
|
||||||
|
Depth must be greater than zero
|
||||||
Warning: json_decode(): Depth must be greater than zero in %s on line %d
|
|
||||||
NULL
|
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue