mirror of
				https://github.com/luanti-org/luanti.git
				synced 2025-11-04 01:05:48 +01:00 
			
		
		
		
	Make SecureRandom non-failable
This commit is contained in:
		@@ -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;
 | 
			
		||||
 
 | 
			
		||||
		Reference in New Issue
	
	Block a user