Software /
code /
prosody
Changeset
8451:770f79a9635c
util.crand: Return early if a zero bytes are requested
author | Kim Alvefur <zash@zash.se> |
---|---|
date | Sun, 03 Dec 2017 15:42:55 +0100 |
parents | 8450:3a9a3d90c44c |
children | 8452:4796fdcb7146 |
files | util-src/crand.c |
diffstat | 1 files changed, 5 insertions(+), 1 deletions(-) [+] |
line wrap: on
line diff
--- a/util-src/crand.c Sun Dec 03 15:37:17 2017 +0100 +++ b/util-src/crand.c Sun Dec 03 15:42:55 2017 +0100 @@ -73,11 +73,15 @@ 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