From 062fd2190e0ac617499b19c51db609d3a923347e Mon Sep 17 00:00:00 2001 From: SmallJoker Date: Wed, 30 Jun 2021 20:42:26 +0200 Subject: [PATCH] Auth API: Error when accessed prior to ServerEnv init (#11398) --- src/script/lua_api/l_auth.cpp | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/src/script/lua_api/l_auth.cpp b/src/script/lua_api/l_auth.cpp index 0fc57ba3a71d..32d8a7411a00 100644 --- a/src/script/lua_api/l_auth.cpp +++ b/src/script/lua_api/l_auth.cpp @@ -32,8 +32,11 @@ AuthDatabase *ModApiAuth::getAuthDb(lua_State *L) { ServerEnvironment *server_environment = dynamic_cast(getEnv(L)); - if (!server_environment) + if (!server_environment) { + luaL_error(L, "Attempt to access an auth function but the auth" + " system is yet not initialized. This causes bugs."); return nullptr; + } return server_environment->getAuthDatabase(); }