1
0
Fork 0
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:
Kim Alvefur 2017-12-03 15:42:55 +01:00
parent 9ed1cb4bec
commit 36ff81d81a

View file

@ -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