mirror of
https://github.com/php/php-src.git
synced 2025-08-15 21:48:51 +02:00
Remove ->last_unsafe
from php_random_status (#9132)
Whenever ->last_unsafe is set to `true` an exception has been thrown. Thus we can replace the check for `->last_unsafe` with a check for `EG(exception)` which is a much more natural way to ommunicate an error up the chain.
This commit is contained in:
parent
60cae26be7
commit
5c693c770a
8 changed files with 13 additions and 24 deletions
|
@ -105,7 +105,7 @@ PHP_METHOD(Random_Randomizer, getInt)
|
|||
zend_throw_exception(spl_ce_RuntimeException, "Generated value exceeds size of int", 0);
|
||||
RETURN_THROWS();
|
||||
}
|
||||
if (randomizer->status->last_unsafe) {
|
||||
if (EG(exception)) {
|
||||
zend_throw_exception(spl_ce_RuntimeException, "Random number generation failed", 0);
|
||||
RETURN_THROWS();
|
||||
}
|
||||
|
@ -123,7 +123,7 @@ PHP_METHOD(Random_Randomizer, getInt)
|
|||
}
|
||||
|
||||
result = randomizer->algo->range(randomizer->status, min, max);
|
||||
if (randomizer->status->last_unsafe) {
|
||||
if (EG(exception)) {
|
||||
zend_throw_exception(spl_ce_RuntimeException, "Random number generation failed", 0);
|
||||
RETURN_THROWS();
|
||||
}
|
||||
|
@ -155,7 +155,7 @@ PHP_METHOD(Random_Randomizer, getBytes)
|
|||
|
||||
while (total_size < required_size) {
|
||||
result = randomizer->algo->generate(randomizer->status);
|
||||
if (randomizer->status->last_unsafe) {
|
||||
if (EG(exception)) {
|
||||
zend_string_free(retval);
|
||||
zend_throw_exception(spl_ce_RuntimeException, "Random number generation failed", 0);
|
||||
RETURN_THROWS();
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue