From b807bbae5603526257db4127da1b1761c9eb8763 Mon Sep 17 00:00:00 2001 From: Aire-One Date: Sat, 22 Jan 2022 17:31:53 +0100 Subject: [PATCH] fix(awesome) randomness Close #3123, close #3124 Co-authored-by: Emmanuel Lepage Vallee --- awesome.c | 10 ++++++++-- 1 file changed, 8 insertions(+), 2 deletions(-) diff --git a/awesome.c b/awesome.c index 24ee52d8..570a4d3a 100644 --- a/awesome.c +++ b/awesome.c @@ -84,10 +84,16 @@ init_rng(void) lua_getfield(L, -1, "randomseed"); /* Push a seed */ - lua_pushnumber(L, g_random_int() + g_random_double()); + lua_pushnumber(L, g_random_int()); /* Call math.randomseed */ - lua_call(L, 1, 0); + if(lua_pcall(L, 1, 0, 0)) + { + warn("Random number generator initialization failed: %s", lua_tostring(L, -1)); + /* Remove error function and error string */ + lua_pop(L, 2); + return; + } /* Remove "math" global */ lua_pop(L, 1);