diff options
-rw-r--r-- | filter/ChangeLog | 13 | ||||
-rw-r--r-- | filter/filter-arg-types.c | 12 | ||||
-rw-r--r-- | filter/filter-driver.c | 12 | ||||
-rw-r--r-- | filter/filter-xml.c | 30 |
4 files changed, 58 insertions, 9 deletions
diff --git a/filter/ChangeLog b/filter/ChangeLog index 84ae5c2b37..d31795348d 100644 --- a/filter/ChangeLog +++ b/filter/ChangeLog @@ -1,3 +1,16 @@ +2000-03-27 NotZed <NotZed@HelixCode.com> + + * filter-xml.c (tokenise_xmlfreeprop): Free a prop after + tokenising it. + (find_node_attr): Free the prop after using it. + (load_desc): Ditto. I use free() because xmlFree() is nowhere to + be found. + (filter_load_optionset): Ditto. + + * filter-arg-types.c (arg_address_values_add_xml): free() xml + stuff, plugs a leak. + (arg_folder_values_add_xml): Ditto. + 2000-03-22 NotZed <NotZed@HelixCode.com> * filter-driver.c (main): Changed to use async search api. diff --git a/filter/filter-arg-types.c b/filter/filter-arg-types.c index ec5cb7b960..f1f0d1236c 100644 --- a/filter/filter-arg-types.c +++ b/filter/filter-arg-types.c @@ -398,7 +398,12 @@ arg_address_values_add_xml(FilterArg *arg, xmlNodePtr node) n = node->childs; while (n) { if (!strcmp(n->name, "address")) { - filter_arg_address_add(arg, xmlGetProp(n, "name"), xmlGetProp(n, "email")); + char *nm, *e; + nm = xmlGetProp(n, "name"); + e = xmlGetProp(n, "email"); + filter_arg_address_add(arg, nm, e); + free(nm); + free(e); } else { g_warning("Loading address from xml, wrong node encountered: %s\n", n->name); } @@ -666,9 +671,10 @@ arg_folder_values_add_xml(FilterArg *arg, xmlNodePtr node) while (n) { if (!strcmp(n->name, "folder")) { char *name = xmlGetProp(n, "name"); - if (name) + if (name) { filter_arg_folder_add(arg, name); - else + free(name); + } else g_warning("no xml prop 'name' on '%s'\n", n->name); } else { g_warning("Loading folders from xml, wrong node encountered: %s\n", n->name); diff --git a/filter/filter-driver.c b/filter/filter-driver.c index 885bf7ddd4..98dbcfd9e4 100644 --- a/filter/filter-driver.c +++ b/filter/filter-driver.c @@ -299,8 +299,20 @@ start(void) x->ex = camel_exception_new (); camel_provider_register_as_module ("../camel/providers/mbox/.libs/libcamelmbox.so.0"); x->session = camel_session_new (auth_callback); + printf("session = %p\n", x->session); x->store = camel_session_get_store (x->session, store_url, x->ex); + printf("store = %p\n", x->store); + if (camel_exception_get_id (x->ex)) { + printf ("Exception caught in camel_store_get_folder\n" + "Full description : %s\n", camel_exception_get_description (x->ex)); + return NULL; + } x->folder = camel_store_get_folder (x->store, "Inbox", x->ex); + if (camel_exception_get_id (x->ex)) { + printf ("Exception caught in camel_store_get_folder\n" + "Full description : %s\n", camel_exception_get_description (x->ex)); + return NULL; + } camel_folder_open (x->folder, FOLDER_OPEN_READ, x->ex); x->terminated = g_hash_table_new(g_str_hash, g_str_equal); x->processed = g_hash_table_new(g_str_hash, g_str_equal); diff --git a/filter/filter-xml.c b/filter/filter-xml.c index b25b1b77af..e59ad5199a 100644 --- a/filter/filter-xml.c +++ b/filter/filter-xml.c @@ -57,6 +57,15 @@ tokenise(const char *name) return -1; } +static int +tokenise_xmlfreeprop(const char *name) +{ + int ret = -1; + ret = tokenise(name); + free(name); + return ret; +} + static char * detokenise(int token) { @@ -94,8 +103,11 @@ find_node_attr(xmlNodePtr start, char *name, char *attrname, char *attrvalue) while ( start && (start = find_node(start, name)) ) { s = xmlGetProp(start, attrname); d(printf(" comparing '%s' to '%s'\n", s, attrvalue)); - if (s && !strcmp(s, attrvalue)) + if (s && !strcmp(s, attrvalue)) { + free(s); break; + } + free(s); start = start->next; } return start; @@ -126,7 +138,7 @@ load_desc(xmlNodePtr node, int type, int vartype, char *varname) newvarname = NULL; } else { newtype = tokenise(node->name); - newvartype = tokenise(xmlGetProp(node, "type")); + newvartype = tokenise_xmlfreeprop(xmlGetProp(node, "type")); newvarname = xmlGetProp(node, "name"); } n = node->childs; @@ -135,6 +147,8 @@ load_desc(xmlNodePtr node, int type, int vartype, char *varname) list = g_list_concat(list, load_desc(n, newtype, newvartype, newvarname)); n = n->next; } + if (newvarname) + free(newvarname); node = node->next; } return list; @@ -157,7 +171,7 @@ filter_load_ruleset(xmlDocPtr doc) rule = ruleset->childs; - ruletype = tokenise(xmlGetProp(ruleset, "type")); + ruletype = tokenise_xmlfreeprop(xmlGetProp(ruleset, "type")); d(printf("ruleset, name = %s\n", ruleset->name)); @@ -298,12 +312,15 @@ filter_load_optionset(xmlDocPtr doc, GList *rules) op = g_malloc0(sizeof(*op)); d(printf("option = %s\n", o->name)); d(printf("option, type=%s\n", xmlGetProp(option, "type"))); - op->type = tokenise(xmlGetProp(option, "type")); + op->type = tokenise_xmlfreeprop(xmlGetProp(option, "type")); while (o) { + char *rulestr; + type = tokenise(o->name); switch (type) { case FILTER_XML_OPTIONRULE: - lrule = g_list_find_custom(rules, xmlGetProp(o, "rule"), (GCompareFunc) filter_find_rule); + rulestr = xmlGetProp(o, "rule"); + lrule = g_list_find_custom(rules, rulestr, (GCompareFunc) filter_find_rule); if (lrule) { fr = lrule->data; d(printf("found rule : %s\n", fr->name)); @@ -329,8 +346,9 @@ filter_load_optionset(xmlDocPtr doc, GList *rules) } } else { /* FIXME: memleak */ - printf("Cannot find rule: %s\n", xmlGetProp(o, "rule")); + printf("Cannot find rule: %s\n", rulestr); } + free(rulestr); break; case FILTER_XML_DESC: d(printf("loading option descriptiong\n")); |