Skip to content

Commit

Permalink
Fix lua error handling issue present in current CivetWeb code
Browse files Browse the repository at this point in the history
Signed-off-by: DL6ER <[email protected]>
  • Loading branch information
DL6ER committed Sep 23, 2024
1 parent 72bfc98 commit 8c92b20
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 8 deletions.
8 changes: 6 additions & 2 deletions src/webserver/civetweb/mod_lua.inl
Original file line number Diff line number Diff line change
Expand Up @@ -674,7 +674,9 @@ run_lsp_kepler(struct mg_connection *conn,

} else {
/* Success loading chunk. Call it. */
lua_pcall(L, 0, 0, 1);
lua_ok = lua_pcall(L, 0, 0, 0);
if(lua_ok != LUA_OK)
lua_cry(conn, lua_ok, L, "LSP", "call");
}
return 0;
}
Expand Down Expand Up @@ -790,7 +792,9 @@ run_lsp_civetweb(struct mg_connection *conn,
lua_pcall(L, 1, 0, 0);
} else {
/* Success loading chunk. Call it. */
lua_pcall(L, 0, 0, 1);
lua_ok = lua_pcall(L, 0, 0, 0);
if(lua_ok != LUA_OK)
lua_cry(conn, lua_ok, L, "LSP", "call");
}

/* Progress until after the Lua closing tag. */
Expand Down
7 changes: 1 addition & 6 deletions src/webserver/lua_web.c
Original file line number Diff line number Diff line change
Expand Up @@ -57,12 +57,7 @@ void free_lua(void)

void init_lua(const struct mg_connection *conn, void *L, unsigned context_flags)
{
// Set onerror handler to print errors to the log
if(luaL_dostring(L, "mg.onerror = function(e) mg.cry('Error at ' .. e) end") != LUA_OK)
{
log_err("Error setting Lua onerror handler: %s", lua_tostring(L, -1));
lua_pop(L, 1);
}
return;
}

int request_handler(struct mg_connection *conn, void *cbdata)
Expand Down

0 comments on commit 8c92b20

Please sign in to comment.