# HG changeset patch # User Kim Alvefur # Date 1512312175 -3600 # Node ID 770f79a9635c24c749114ea32e789a592e2678a7 # Parent 3a9a3d90c44cfe369886964d61e3f1198ddb38ad util.crand: Return early if a zero bytes are requested diff -r 3a9a3d90c44c -r 770f79a9635c util-src/crand.c --- 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