mirror of
https://github.com/bjc/prosody.git
synced 2025-04-06 14:47:37 +03:00
util.crand: Return early if a zero bytes are requested
This commit is contained in:
parent
9ed1cb4bec
commit
36ff81d81a
1 changed files with 5 additions and 1 deletions
|
@ -73,11 +73,15 @@ int Lrandom(lua_State *L) {
|
|||
const size_t len = l;
|
||||
luaL_argcheck(L, l >= 0, 1, "must be > 0");
|
||||
|
||||
if(len == 0) {
|
||||
lua_pushliteral(L, "");
|
||||
return 1;
|
||||
}
|
||||
|
||||
if(len > SMALLBUFSIZ) {
|
||||
buf = lua_newuserdata(L, len);
|
||||
}
|
||||
|
||||
|
||||
#if defined(WITH_GETRANDOM)
|
||||
/*
|
||||
* This acts like a read from /dev/urandom with the exception that it
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue