summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorPřemysl Janouch <p.janouch@gmail.com>2016-01-06 00:23:54 +0100
committerPřemysl Janouch <p.janouch@gmail.com>2016-01-06 00:23:54 +0100
commita259e964050bf66a39ea4ce751583ffe3f391dd3 (patch)
tree9104c72f1f3c7c153e33ae86a1ab32083c33babc
parenta7be2bf160a7bd76915617b89662d240b70ad1d4 (diff)
downloadxK-a259e964050bf66a39ea4ce751583ffe3f391dd3.tar.gz
xK-a259e964050bf66a39ea4ce751583ffe3f391dd3.tar.xz
xK-a259e964050bf66a39ea4ce751583ffe3f391dd3.zip
degesch: Lua: fix a resource leak
-rw-r--r--degesch.c8
1 files changed, 6 insertions, 2 deletions
diff --git a/degesch.c b/degesch.c
index d88b3bd..a2a0d23 100644
--- a/degesch.c
+++ b/degesch.c
@@ -7638,16 +7638,20 @@ lua_plugin_call (struct lua_plugin *self,
int n_params, int n_results, struct error **e)
{
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;
lua_insert (L, error_handler_idx);
if (!lua_pcall (L, n_params, n_results, error_handler_idx))
+ {
+ lua_remove (L, -n_results - 1);
return true;
+ }
(void) lua_plugin_process_error (self, lua_tostring (L, -1), e);
- lua_pop (L, 1);
+ lua_pop (L, 2);
return false;
}