tb = lua_touserdata (L, -1);
msg_err_config ("error executing post load code: %v", tb);
g_string_free (tb, TRUE);
- lua_pop (L, 2);
+ lua_settop (L, err_idx - 1);
return FALSE;
}
- lua_pop (L, 1); /* Error function */
+ lua_settop (L, err_idx - 1);
}
return TRUE;
static gsize
lua_logger_out_userdata (lua_State *L, gint pos, gchar *outbuf, gsize len)
{
- gint r;
+ gint r, top;
const gchar *str = NULL;
+ top = lua_gettop (L);
+
if (!lua_getmetatable (L, pos)) {
return 0;
}
lua_gettable (L, -2);
if (!lua_istable (L, -1)) {
- lua_pop (L, 2);
+ lua_settop (L, top);
+
return 0;
}
lua_pushvalue (L, pos);
if (lua_pcall (L, 1, 1, 0) != 0) {
- lua_pop (L, 3);
+ lua_settop (L, top);
+
return 0;
}
lua_gettable (L, -2);
if (!lua_isstring (L, -1)) {
- lua_pop (L, 3);
+ lua_settop (L, top);
+
return 0;
}
}
r = rspamd_snprintf (outbuf, len + 1, "%s(%p)", str, lua_touserdata (L, pos));
- lua_pop (L, 3);
+ lua_settop (L, top);
return r;
}
}
}
+#ifdef __GNUC__
+static void
+lua_tcp_push_error (struct lua_tcp_cbdata *cbd, gboolean is_fatal,
+ const char *err, ...) __attribute__ ((format(printf, 3, 4)));
+#endif
+
static void
lua_tcp_push_error (struct lua_tcp_cbdata *cbd, gboolean is_fatal,
const char *err, ...)
va_list ap, ap_copy;
struct lua_tcp_cbdata **pcbd;
struct lua_tcp_handler *hdl;
- gint cbref;
+ gint cbref, top;
va_start (ap, err);
hdl = g_queue_peek_head (cbd->handlers);
if (hdl == NULL) {
- va_end (ap_copy);
break;
}
}
if (cbref != -1) {
+ top = lua_gettop (cbd->L);
lua_rawgeti (cbd->L, LUA_REGISTRYINDEX, cbref);
/* Error message */
if (lua_pcall (cbd->L, 3, 0, 0) != 0) {
msg_info ("callback call failed: %s", lua_tostring (cbd->L, -1));
- lua_pop (cbd->L, 1);
}
+ lua_settop (cbd->L, top);
+
REF_RELEASE (cbd);
}
struct rspamd_lua_text *t;
struct lua_tcp_cbdata **pcbd;
struct lua_tcp_handler *hdl;
- gint cbref, arg_cnt;
+ gint cbref, arg_cnt, top;
hdl = g_queue_peek_head (cbd->handlers);
}
if (cbref != -1) {
+ top = lua_gettop (cbd->L);
lua_rawgeti (cbd->L, LUA_REGISTRYINDEX, cbref);
/* Error */
lua_pushnil (cbd->L);
if (lua_pcall (cbd->L, arg_cnt, 0, 0) != 0) {
msg_info ("callback call failed: %s", lua_tostring (cbd->L, -1));
- lua_pop (cbd->L, 1);
}
+ lua_settop (cbd->L, top);
REF_RELEASE (cbd);
}
}
if (cbd->connect_cb != -1) {
struct lua_tcp_cbdata **pcbd;
+ gint top;
+ top = lua_gettop (cbd->L);
lua_rawgeti (cbd->L, LUA_REGISTRYINDEX, cbd->connect_cb);
pcbd = lua_newuserdata (cbd->L, sizeof (*pcbd));
*pcbd = cbd;
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);
}
+ lua_settop (cbd->L, top);
+
REF_RELEASE (cbd);
}
}