commit c33af58: [Minor] Fix stupid memory leak

Vsevolod Stakhov vsevolod at highsecure.ru
Thu Sep 2 12:35:04 UTC 2021


Author: Vsevolod Stakhov
Date: 2021-09-02 13:32:09 +0100
URL: https://github.com/rspamd/rspamd/commit/c33af58a53b686b18a0236a5cca62ae3e0322fc2 (HEAD -> master)

[Minor] Fix stupid memory leak

---
 src/libmime/message.h           |  3 +--
 src/libserver/html/html_tag.hxx |  3 +++
 src/rspamadm/commands.c         | 13 +++++++------
 3 files changed, 11 insertions(+), 8 deletions(-)

diff --git a/src/libmime/message.h b/src/libmime/message.h
index 25bf70f77..a391daf0d 100644
--- a/src/libmime/message.h
+++ b/src/libmime/message.h
@@ -26,7 +26,6 @@ extern "C" {
 
 struct rspamd_task;
 struct controller_session;
-struct html_content;
 struct rspamd_image;
 struct rspamd_archive;
 
@@ -144,7 +143,7 @@ struct rspamd_mime_text_part {
 	UText utf_stripped_text; /* Used by libicu to represent the utf8 content */
 
 	GPtrArray *newlines;    /**< positions of newlines in text, relative to content*/
-	struct html_content *html;
+	void *html;
 	GList *exceptions;    /**< list of offsets of urls						*/
 	struct rspamd_mime_part *mime_part;
 
diff --git a/src/libserver/html/html_tag.hxx b/src/libserver/html/html_tag.hxx
index 357e11bfb..b6fc73120 100644
--- a/src/libserver/html/html_tag.hxx
+++ b/src/libserver/html/html_tag.hxx
@@ -26,6 +26,9 @@
 
 #include "html_tags.h"
 
+struct rspamd_url;
+struct html_image;
+
 namespace rspamd::html {
 
 enum class html_component_type : std::uint8_t {
diff --git a/src/rspamadm/commands.c b/src/rspamadm/commands.c
index 9f243c707..aabf6747e 100644
--- a/src/rspamadm/commands.c
+++ b/src/rspamadm/commands.c
@@ -128,14 +128,12 @@ static const gchar *
 rspamadm_lua_command_help (gboolean full_help,
 						  const struct rspamadm_command *cmd)
 {
-	struct thread_entry *thread = lua_thread_pool_get_for_config (rspamd_main->cfg);
-
-	lua_State *L = thread->lua_state;
-
 	gint table_idx = GPOINTER_TO_INT (cmd->command_data);
 
 	if (full_help) {
+		struct thread_entry *thread = lua_thread_pool_get_for_config (rspamd_main->cfg);
 
+		lua_State *L = thread->lua_state;
 		lua_rawgeti (L, LUA_REGISTRYINDEX, table_idx);
 		/* Function */
 		lua_pushstring (L, "handler");
@@ -152,8 +150,11 @@ rspamadm_lua_command_help (gboolean full_help,
 		if (lua_repl_thread_call (thread, 1, (void *)cmd, lua_thread_str_error_cb) != 0) {
 			exit (EXIT_FAILURE);
 		}
+
+		lua_settop (L, 0);
 	}
 	else {
+		lua_State *L = rspamd_main->cfg->lua_state;
 		lua_rawgeti (L, LUA_REGISTRYINDEX, table_idx);
 		lua_pushstring (L, "description");
 		lua_gettable (L, -2);
@@ -164,9 +165,9 @@ rspamadm_lua_command_help (gboolean full_help,
 		else {
 			printf ("  %-18s %-60s\n", cmd->name, "no description available");
 		}
-	}
 
-	lua_settop (L, 0);
+		lua_settop (L, 0);
+	}
 
 	return NULL; /* Must be handled in rspamadm itself */
 }


More information about the Commits mailing list