Make SecureRandom non-failable

This commit is contained in:
Daniel Hajjar 2024-08-20 11:49:15 +02:00 committed by GitHub
parent b010714426
commit ec115ffe2a
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
2 changed files with 2 additions and 3 deletions

@ -8669,7 +8669,7 @@ In multiplayer mode, the error may be arbitrarily large.
Interface for the operating system's crypto-secure PRNG.
It can be created via `SecureRandom()`. The constructor returns nil if a
It can be created via `SecureRandom()`. The constructor throws an error if a
secure random device cannot be found on the system.
### Methods

@ -641,10 +641,9 @@ int LuaSecureRandom::create_object(lua_State *L)
{
LuaSecureRandom *o = new LuaSecureRandom();
// Fail and return nil if we can't securely fill the buffer
if (!o->fillRandBuf()) {
delete o;
return 0;
throw LuaError("SecureRandom: Failed to find secure random device on system");
}
*(void **)(lua_newuserdata(L, sizeof(void *))) = o;