degesch: Lua: fix a resource leak

This commit is contained in:
Přemysl Eric Janouch 2016-01-06 00:23:54 +01:00
parent a7be2bf160
commit a259e96405
1 changed files with 6 additions and 2 deletions

View File

@ -7638,16 +7638,20 @@ lua_plugin_call (struct lua_plugin *self,
int n_params, int n_results, struct error **e) int n_params, int n_results, struct error **e)
{ {
lua_State *L = self->L; lua_State *L = self->L;
lua_pushcfunction (L, lua_plugin_error_handler);
// We need to pop the error handler at the end
lua_pushcfunction (L, lua_plugin_error_handler);
int error_handler_idx = -n_params - 2; int error_handler_idx = -n_params - 2;
lua_insert (L, error_handler_idx); lua_insert (L, error_handler_idx);
if (!lua_pcall (L, n_params, n_results, error_handler_idx)) if (!lua_pcall (L, n_params, n_results, error_handler_idx))
{
lua_remove (L, -n_results - 1);
return true; return true;
}
(void) lua_plugin_process_error (self, lua_tostring (L, -1), e); (void) lua_plugin_process_error (self, lua_tostring (L, -1), e);
lua_pop (L, 1); lua_pop (L, 2);
return false; return false;
} }