From bdf0d91f8aeec07b6959a41fa2965731ca2dcdcd Mon Sep 17 00:00:00 2001 From: DL6ER Date: Mon, 23 Sep 2024 13:07:33 +0200 Subject: [PATCH] Abort early on Lua errors Signed-off-by: DL6ER --- src/webserver/civetweb/mod_lua.inl | 17 +++++++++++++---- 1 file changed, 13 insertions(+), 4 deletions(-) diff --git a/src/webserver/civetweb/mod_lua.inl b/src/webserver/civetweb/mod_lua.inl index 739f1a2e..62cb54f1 100644 --- a/src/webserver/civetweb/mod_lua.inl +++ b/src/webserver/civetweb/mod_lua.inl @@ -670,13 +670,17 @@ run_lsp_kepler(struct mg_connection *conn, /* Syntax error or OOM. * Error message is pushed on stack. */ lua_pcall(L, 1, 0, 0); - lua_cry(conn, lua_ok, L, "LSP", "execute"); /* XXX TODO: everywhere ! */ + lua_cry(conn, lua_ok, L, "LSP Kepler", "execute"); + return 1; } else { /* Success loading chunk. Call it. */ lua_ok = lua_pcall(L, 0, 0, 0); - if(lua_ok != LUA_OK) - lua_cry(conn, lua_ok, L, "LSP", "call"); + if(lua_ok != LUA_OK) + { + lua_cry(conn, lua_ok, L, "LSP Kepler", "call"); + return 1; + } } return 0; } @@ -790,11 +794,16 @@ run_lsp_civetweb(struct mg_connection *conn, /* Syntax error or OOM. * Error message is pushed on stack. */ lua_pcall(L, 1, 0, 0); + lua_cry(conn, lua_ok, L, "LSP", "execute"); + return 1; } else { /* Success loading chunk. Call it. */ lua_ok = lua_pcall(L, 0, 0, 0); - if(lua_ok != LUA_OK) + if(lua_ok != LUA_OK) + { lua_cry(conn, lua_ok, L, "LSP", "call"); + return 1; + } } /* Progress until after the Lua closing tag. */