From: Vsevolod Stakhov Date: Fri, 14 Oct 2011 18:22:29 +0000 (+0300) Subject: Fix stupid bug with lua stack corruption. X-Git-Tag: 0.4.5~56 X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=f355b1b4948b0f394e024b6bbc6ad0ec26c39eff;p=thirdparty%2Frspamd.git Fix stupid bug with lua stack corruption. --- diff --git a/src/lua/lua_classifier.c b/src/lua/lua_classifier.c index 32d4f88ed3..0bf0daca8f 100644 --- a/src/lua/lua_classifier.c +++ b/src/lua/lua_classifier.c @@ -109,7 +109,6 @@ call_classifier_pre_callback (struct classifier_config *ccf, struct worker_task lua_pop (L, 1); } } - lua_pop (L, 1); } return res; diff --git a/src/lua/lua_common.c b/src/lua/lua_common.c index 67206b8ef3..990be90ef5 100644 --- a/src/lua/lua_common.c +++ b/src/lua/lua_common.c @@ -384,12 +384,15 @@ lua_call_expression_func (const gchar *module, const gchar *function, lua_pop (L, 1); lua_getglobal (L, function); } - else { + else if (lua_istable (L, -1)) { /* Call local function in table */ lua_pushstring (L, function); lua_gettable (L, -2); pop += 2; } + else { + msg_err ("Bad type: %s for function: %s for module: %s", lua_typename (L, lua_type (L, -1)), function, module); + } } else { /* Try to get global variable */ @@ -441,6 +444,8 @@ lua_call_expression_func (const gchar *module, const gchar *function, return FALSE; } *res = lua_toboolean (L, -1); + lua_gc (L, LUA_GCCOLLECT, 0); + msg_info ("lua eats %d kbytes", lua_gc (L, LUA_GCCOUNT, 0)); lua_pop (L, pop); return TRUE;