diff options
author | Kim Alvefur <zash@zash.se> | 2017-12-03 15:42:55 +0100 |
---|---|---|
committer | Kim Alvefur <zash@zash.se> | 2017-12-03 15:42:55 +0100 |
commit | 442fb34ca00bddf98cabd90f1175ff134b190c8a (patch) | |
tree | 3eeb5e6a7675b2aea5152323993d13b37a06c3a6 /util-src | |
parent | 09000b3a82fbf035276fe8415c9f89b32e2ed567 (diff) | |
download | prosody-442fb34ca00bddf98cabd90f1175ff134b190c8a.tar.gz prosody-442fb34ca00bddf98cabd90f1175ff134b190c8a.zip |
util.crand: Return early if a zero bytes are requested
Diffstat (limited to 'util-src')
-rw-r--r-- | util-src/crand.c | 6 |
1 files changed, 5 insertions, 1 deletions
diff --git a/util-src/crand.c b/util-src/crand.c index 20871f3e..160ac1f6 100644 --- a/util-src/crand.c +++ b/util-src/crand.c @@ -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 |