diff options
author | Vsevolod Stakhov <vsevolod@highsecure.ru> | 2016-02-05 12:42:43 +0000 |
---|---|---|
committer | Vsevolod Stakhov <vsevolod@highsecure.ru> | 2016-02-05 12:42:43 +0000 |
commit | b35299b4e3a6cf75cfa19783dda35411508d2913 (patch) | |
tree | da78386cf112c62a0bf81fd04f4d243660e24f28 /src/lua/lua_expression.c | |
parent | f29fb4de499b145b29a1cb22b0f7c0f81473ff6b (diff) | |
download | rspamd-b35299b4e3a6cf75cfa19783dda35411508d2913.tar.gz rspamd-b35299b4e3a6cf75cfa19783dda35411508d2913.zip |
Fix leaks in lua error paths
Diffstat (limited to 'src/lua/lua_expression.c')
-rw-r--r-- | src/lua/lua_expression.c | 12 |
1 files changed, 8 insertions, 4 deletions
diff --git a/src/lua/lua_expression.c b/src/lua/lua_expression.c index 5bb7293eb..fe52e929b 100644 --- a/src/lua/lua_expression.c +++ b/src/lua/lua_expression.c @@ -135,6 +135,8 @@ lua_atom_parse (const gchar *line, gsize len, if (lua_pcall (e->L, 1, 1, 0) != 0) { msg_info ("callback call failed: %s", lua_tostring (e->L, -1)); + lua_pop (e->L, 1); + return NULL; } if (lua_type (e->L, -1) != LUA_TSTRING) { @@ -158,7 +160,7 @@ static gint lua_atom_process (gpointer input, rspamd_expression_atom_t *atom) { struct lua_expression *e = (struct lua_expression *)atom->data; - gint ret; + gint ret = 0; lua_rawgeti (e->L, LUA_REGISTRYINDEX, e->process_idx); lua_pushlstring (e->L, atom->str, atom->len); @@ -166,10 +168,12 @@ lua_atom_process (gpointer input, rspamd_expression_atom_t *atom) if (lua_pcall (e->L, 2, 1, 0) != 0) { msg_info ("callback call failed: %s", lua_tostring (e->L, -1)); + lua_pop (e->L, 1); + } + else { + ret = lua_tonumber (e->L, -1); + lua_pop (e->L, 1); } - - ret = lua_tonumber (e->L, -1); - lua_pop (e->L, 1); return ret; } |