[Commits] [SCM] claws branch, master, updated. 3.15.0-110-gcfbe405

ticho at claws-mail.org ticho at claws-mail.org
Sun Jul 16 12:22:19 CEST 2017


The branch, master has been updated
       via  cfbe405f11fd8e87b13c34ba4c00a4ee5cffcd32 (commit)
      from  57e6203525cd1238f5f7164ba2587c50a603d2c4 (commit)

Summary of changes:
 src/matcher_parser_parse.y |   15 +++++++++++++++
 1 file changed, 15 insertions(+)


- Log -----------------------------------------------------------------
commit cfbe405f11fd8e87b13c34ba4c00a4ee5cffcd32
Author: Andrej Kacian <ticho at claws-mail.org>
Date:   Sun Jul 16 12:18:03 2017 +0200

    Second attempt at fixing the memory leak in matcherrc rule parsing.
    
    This time, we take into account that the memory allocated by
    yyparse() uses is sometimes used and freed by another
    function higher in the stack.

diff --git a/src/matcher_parser_parse.y b/src/matcher_parser_parse.y
index dd2aee7..ea37c44 100644
--- a/src/matcher_parser_parse.y
+++ b/src/matcher_parser_parse.y
@@ -50,6 +50,7 @@ static gboolean matcher_is_fast = TRUE;
 static gboolean disable_warnings = FALSE;
 
 static FilteringProp *filtering;
+static gboolean filtering_ptr_externally_managed = FALSE;
 
 static GSList **prefs_filtering = NULL;
 static int enable_compatibility = 0;
@@ -112,11 +113,16 @@ FilteringProp *matcher_parser_get_filtering(gchar *str)
         matcher_parser_init();
 	bufstate = matcher_parser_scan_string((const char *) tmp_str);
         matcher_parser_switch_to_buffer(bufstate);
+	/* Indicate that we will be using the global "filtering" pointer,
+	 * so that yyparse does not free it in "filtering_action_list"
+	 * section. */
+	filtering_ptr_externally_managed = TRUE;
 	if (matcher_parserparse() != 0)
 		filtering = NULL;
 	matcher_parse_op = MATCHER_PARSE_FILE;
 	matcher_parser_delete_buffer(bufstate);
 	g_free(tmp_str);
+	filtering_ptr_externally_managed = FALSE; /* Return to normal. */
 	return filtering;
 }
 
@@ -537,6 +543,15 @@ filtering_action_list
 		*prefs_filtering = g_slist_append(*prefs_filtering,
 						  filtering);
 		filtering = NULL;
+	} else if (!filtering_ptr_externally_managed) {
+		/* If filtering_ptr_externally_managed was TRUE, it
+		 * would mean that some function higher in the stack is
+		 * interested in the data "filtering" is pointing at, so
+		 * we would not free it. That function has to free it itself.
+		 * At the time of writing this, the only function that
+		 * does this is matcher_parser_get_filtering(). */
+		filteringprop_free(filtering);
+		filtering = NULL;
 	}
 }
 ;

-----------------------------------------------------------------------


hooks/post-receive
-- 
Claws Mail


More information about the Commits mailing list