mirror of
http://git.haproxy.org/git/haproxy.git/
synced 2024-12-19 01:54:37 +00:00
BUG/MINOR: lua: Fix lua error handling in hlua_config_prepend_path()
Set an `lua_atpanic()` handler before calling `hlua_prepend_path()` in `hlua_config_prepend_path()`. This prevents the process from abort()ing when `hlua_prepend_path()` fails for some reason. see GitHub Issue #1409 This is a very minor issue that can't happen in practice. No backport needed.
This commit is contained in:
parent
8c67eceeca
commit
9e5e586e35
27
src/hlua.c
27
src/hlua.c
@ -11167,8 +11167,31 @@ static int hlua_config_prepend_path(char **args, int section_type, struct proxy
|
||||
}
|
||||
LIST_APPEND(&prepend_path_list, &p->l);
|
||||
|
||||
hlua_prepend_path(hlua_states[0], type, path);
|
||||
hlua_prepend_path(hlua_states[1], type, path);
|
||||
/* Handle the global state and the per-thread state for the first
|
||||
* thread. The remaining threads will be initialized based on
|
||||
* prepend_path_list.
|
||||
*/
|
||||
for (size_t i = 0; i < 2; i++) {
|
||||
lua_State *L = hlua_states[i];
|
||||
const char *error;
|
||||
|
||||
if (setjmp(safe_ljmp_env) != 0) {
|
||||
lua_atpanic(L, hlua_panic_safe);
|
||||
if (lua_type(L, -1) == LUA_TSTRING)
|
||||
error = lua_tostring(L, -1);
|
||||
else
|
||||
error = "critical error";
|
||||
fprintf(stderr, "lua-prepend-path: %s.\n", error);
|
||||
exit(1);
|
||||
} else {
|
||||
lua_atpanic(L, hlua_panic_ljmp);
|
||||
}
|
||||
|
||||
hlua_prepend_path(L, type, path);
|
||||
|
||||
lua_atpanic(L, hlua_panic_safe);
|
||||
}
|
||||
|
||||
return 0;
|
||||
|
||||
err2:
|
||||
|
Loading…
Reference in New Issue
Block a user