mime_atom->d.lua_function,
mime_atom->str,
lua_tostring (L, -1));
+ lua_pop (L, 1);
}
else {
if (lua_type (L, -1) == LUA_TBOOLEAN) {
lua_src,
tb->str);
g_string_free (tb, TRUE);
- lua_pop (L, 1);
+ lua_pop (L, 2);
if (chdir (cur_dir) == -1) {
msg_err_config ("cannot chdir to %s: %s", cur_dir,
if (lua_pcall (cfg->lua_state, 0, 1, 0) != 0) {
msg_err_config ("error executing lua code: '%T': %s", content,
lua_tostring (cfg->lua_state, -1));
+ lua_pop (cfg->lua_state, 1);
+
return FALSE;
}
if (lua_pcall (L, 1, 1, 0) != 0) {
msg_info_task ("call to condition for %s failed: %s",
item->symbol, lua_tostring (L, -1));
+ lua_pop (L, 1);
}
else {
check = lua_toboolean (L, -1);
if (lua_pcall (L, 1, 1, 0) != 0) {
msg_err_task ("call to log function failed: %s",
lua_tostring (L, -1));
+ lua_pop (L, 1);
}
else {
lua_str = lua_tolstring (L, -1, &lua_str_len);
if (lua_pcall (cbdata->L, 2, 1, 0) != 0) {
msg_info ("call to session finalizer failed: %s",
lua_tostring (cbdata->L, -1));
+ lua_pop (cbdata->L, 1);
}
res = lua_toboolean (cbdata->L, -1);
if (lua_pcall (cbdata->L, 1, 1, 0) != 0) {
msg_info ("call to session finalizer failed: %s",
lua_tostring (cbdata->L, -1));
+ lua_pop (cbdata->L, 1);
}
res = lua_toboolean (cbdata->L, -1);
if (lua_pcall (cbdata->L, 2, 0, 0) != 0) {
msg_info ("call to session finalizer failed: %s",
lua_tostring (cbdata->L, -1));
+ lua_pop (cbdata->L, 1);
}
/* Unref callbacks */
if (lua_pcall (L, 4, 1, 0) != 0) {
msg_warn_task ("error running pre classifier callback %s",
lua_tostring (L, -1));
+ lua_pop (L, 1);
}
else {
if (lua_istable (L, -1)) {
lua_pop (L, 1);
}
}
+ lua_pop (L, 1);
}
return res;
if (lua_pcall (L, 3, 1, 0) != 0) {
msg_warn_task ("error running function %s: %s", cd->name,
lua_tostring (L, -1));
+ lua_pop (L, 1);
}
else {
if (lua_isnumber (L, 1)) {
gint
rspamd_lua_call_filter (const gchar *function, struct rspamd_task *task)
{
- gint result;
+ gint result = 0;
struct rspamd_task **ptask;
lua_State *L = task->cfg->lua_state;
if (!lua_isnumber (L, -1)) {
msg_info_task ("function %s must return a number", function);
}
- result = lua_tonumber (L, -1);
+ else {
+ result = lua_tonumber (L, -1);
+ }
+
lua_pop (L, 1); /* pop returned value */
return result;
cd->cb_is_ref ? "local function" :
cd->callback.name,
lua_tostring (cd->L, -1));
+ lua_pop (cd->L, 1);
}
cur = g_list_next (cur);
}
cd->cb_is_ref ? "local function" :
cd->callback.name,
lua_tostring (cd->L, -1));
+ lua_pop (cd->L, 1);
}
cur = g_list_next (cur);
}
}
rspamd_task_insert_result (task, cd->symbol, flag, opts);
}
+
+ lua_pop (L, nresults);
}
- lua_pop (L, nresults);
}
}
if (lua_pcall (cbdata->L, 1, 0, 0) != 0) {
msg_info_pool ("call to %s failed: %s", "local function",
lua_tostring (cbdata->L, -1));
+ lua_pop (cbdata->L, 1);
}
}
}
if (lua_pcall (cd->L, 5, 0, 0) != 0) {
msg_info ("call to dns callback failed: %s", lua_tostring (cd->L, -1));
+ lua_pop (cd->L, 1);
}
/* Unref function */
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) {
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);
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;
}
if (lua_pcall (cbd->L, 1, 0, 0) != 0) {
msg_info ("callback call failed: %s", lua_tostring (cbd->L, -1));
+ lua_pop (cbd->L, 1);
}
}
}
if (lua_pcall (cbd->L, 4, 0, 0) != 0) {
msg_info ("callback call failed: %s", lua_tostring (cbd->L, -1));
+ lua_pop (cbd->L, 1);
}
lua_http_maybe_free (cbd);
lua_rawgeti (ud->L, LUA_REGISTRYINDEX, ud->cbref);
if (lua_pcall (ud->L, 0, 0, 0) != 0) {
msg_info ("call to destructor failed: %s", lua_tostring (ud->L, -1));
+ lua_pop (ud->L, 1);
}
luaL_unref (ud->L, LUA_REGISTRYINDEX, ud->cbref);
}
lua_pushnil (ud->L);
if (lua_pcall (ud->L, 3, 0, 0) != 0) {
msg_info ("call to callback failed: %s", lua_tostring (ud->L, -1));
+ lua_pop (ud->L, 1);
}
if (connected) {
if (lua_pcall (ud->L, 3, 0, 0) != 0) {
msg_info ("call to callback failed: %s", lua_tostring (ud->L, -1));
+ lua_pop (ud->L, 1);
}
rspamd_session_remove_event (ud->task->s, lua_redis_fin, ctx);
if (lua_pcall (cbdata->L, 0, 1, 0) != 0) {
msg_info ("call to session finalizer failed: %s",
lua_tostring (cbdata->L, -1));
+ lua_pop (cbdata->L, 1);
}
- res = lua_toboolean (cbdata->L, -1);
- lua_pop (cbdata->L, 1);
+ else {
+ res = lua_toboolean (cbdata->L, -1);
+ lua_pop (cbdata->L, 1);
+ }
+
luaL_unref (cbdata->L, LUA_REGISTRYINDEX, cbdata->cbref_fin);
if (lua_pcall (cbdata->L, 0, 0, 0) != 0) {
msg_info ("call to session restorer failed: %s",
lua_tostring (cbdata->L, -1));
+ lua_pop (cbdata->L, 1);
}
luaL_unref (cbdata->L, LUA_REGISTRYINDEX, cbdata->cbref_restore);
}
if (lua_pcall (cbdata->L, 0, 0, 0) != 0) {
msg_info ("call to session cleanup failed: %s",
lua_tostring (cbdata->L, -1));
+ lua_pop (cbdata->L, 1);
}
luaL_unref (cbdata->L, LUA_REGISTRYINDEX, cbdata->cbref_cleanup);
}
if (lua_pcall (cbdata->L, 0, 0, 0) != 0) {
msg_info ("call to event finalizer failed: %s",
lua_tostring (cbdata->L, -1));
+ lua_pop (cbdata->L, 1);
}
luaL_unref (cbdata->L, LUA_REGISTRYINDEX, cbdata->cbref);
}
if (lua_pcall (cbd->L, 1, 0, 0) != 0) {
msg_info ("callback call failed: %s", lua_tostring (cbd->L, -1));
+ lua_pop (cbd->L, 1);
}
}
if (lua_pcall (cbd->L, 2, 0, 0) != 0) {
msg_info ("callback call failed: %s", lua_tostring (cbd->L, -1));
+ lua_pop (cbd->L, 1);
}
}
if (lua_pcall (L, 2, 1, 0) != 0) {
msg_info ("call to trie callback has failed: %s",
lua_tostring (L, -1));
+ lua_pop (L, 1);
return 1;
}
if (lua_pcall (L, 4, 0, 0) != 0) {
msg_info ("call to worker accept failed: %s", lua_tostring (L, -1));
+ lua_pop (L, 1);
}
rspamd_inet_address_destroy (addr);
if (lua_pcall (L, 1, 0, 0) != 0) {
msg_info ("call to worker finalizer failed: %s", lua_tostring (L,
-1));
+ lua_pop (L, 1);
}
/* Free resources */
luaL_unref (L, LUA_REGISTRYINDEX, ctx->cbref_fin);
if (lua_pcall (L, nargs + 1, 1, 0) != 0) {
msg_info_task ("%s: call to lua function failed: %s", symbol,
lua_tostring (L, -1));
+ lua_pop (L, 1);
+
return FALSE;
}
+
pop++;
if (lua_type (L, -1) == LUA_TNUMBER) {
g_string_free (tb, TRUE);
}
- lua_pop (L, 1);
+ lua_pop (L, 2);
return FALSE;
}