Replace RuntimeException in Randomizer::nextInt() by RandomException (#9305)

* Replace RuntimeException in Randomizer::nextInt() by RandomException

* Add ext/random/tests/03_randomizer/nextint_error.phpt
This commit is contained in:
Tim Düsterhus 2022-08-15 11:06:03 +02:00 committed by GitHub
parent 4b7a98754d
commit 3b48a2044d
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
4 changed files with 22 additions and 5 deletions

View file

@ -24,7 +24,6 @@
#include "ext/standard/php_array.h"
#include "ext/standard/php_string.h"
#include "ext/spl/spl_exceptions.h"
#include "Zend/zend_exceptions.h"
static inline void randomizer_common_init(php_random_randomizer *randomizer, zend_object *engine_object) {
@ -102,7 +101,7 @@ PHP_METHOD(Random_Randomizer, nextInt)
RETURN_THROWS();
}
if (randomizer->status->last_generated_size > sizeof(zend_long)) {
zend_throw_exception(spl_ce_RuntimeException, "Generated value exceeds size of int", 0);
zend_throw_exception(random_ce_Random_RandomException, "Generated value exceeds size of int", 0);
RETURN_THROWS();
}