aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--util-src/crand.c6
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