[evolution-rss] fix a bunch of memleaks
- From: Lucian Langa <lucilanga src gnome org>
- To: svn-commits-list gnome org
- Cc:
- Subject: [evolution-rss] fix a bunch of memleaks
- Date: Fri, 25 Sep 2009 18:08:17 +0000 (UTC)
commit 13f2dc6b12102606fbff2107f00838314ce6d670
Author: Lucian Langa <lucilanga gnome org>
Date: Fri Sep 25 21:05:28 2009 +0300
fix a bunch of memleaks
TODO | 1 -
src/network-soup.c | 1 +
src/parser.c | 13 +++++++----
src/rss-config-factory.c | 2 +-
src/rss.c | 53 +++++++++++++++++++++++++++++++++------------
5 files changed, 49 insertions(+), 21 deletions(-)
---
diff --git a/TODO b/TODO
index 6533308..c6e586f 100644
--- a/TODO
+++ b/TODO
@@ -42,7 +42,6 @@
* check rss_delete_feed for race condition when deletion of camel folder
* folder delete should delete feed_folders allocation
* fix comment cancellation
- * check modality of new windows/dialogs
* fix wrong SSL browser dialog
* check custom interval fetching right after it was setup
diff --git a/src/network-soup.c b/src/network-soup.c
index 983a85a..e3f9478 100644
--- a/src/network-soup.c
+++ b/src/network-soup.c
@@ -771,6 +771,7 @@ rss_soup_init(void)
gchar *feed_dir = rss_component_peek_base_directory();
gchar *cookie_path = g_build_path("/", feed_dir, "rss-cookies.sqlite", NULL);
gchar *moz_cookie_path = g_build_path("/", feed_dir, "mozembed-rss", "cookies.sqlite", NULL);
+ g_free(feed_dir);
rss_soup_jar =
soup_cookie_jar_sqlite_new (cookie_path, FALSE);
diff --git a/src/parser.c b/src/parser.c
index b61b227..1ae9801 100644
--- a/src/parser.c
+++ b/src/parser.c
@@ -374,6 +374,7 @@ layer_find_all (xmlNodePtr node,
if (strcasecmp ((char *)node->name, match)==0) {
while (node!=NULL && strcasecmp ((char *)node->name, match)==0) {
if (node->children != NULL && node->children->content != NULL) {
+ /* FIXME */
category = g_list_append(category, g_strdup((char *)node->children->content));
}
node = node->next;
@@ -512,10 +513,10 @@ layer_find_tag (xmlNodePtr node,
//this looses html entities
len = xmlNodeDump(buf, node->doc, node, 0, 0);
content = g_strdup_printf("%s", xmlBufferContent(buf));
- xmlBufferFree(buf);
} else {
content = (char *)xmlNodeGetContent(node);
}
+ xmlBufferFree(buf);
if (nodetype)
xmlFree(nodetype);
return content;
@@ -836,6 +837,7 @@ parse_channel_line(xmlNode *top, gchar *feed_name, char *main_date)
char *q = NULL;
char *b = NULL;
char *d2 = NULL;
+ char *sp = NULL;
gchar *feed = NULL;
gchar *encl;
xmlChar *buff = NULL;
@@ -953,7 +955,7 @@ parse_channel_line(xmlNode *top, gchar *feed_name, char *main_date)
//not very nice but prevents unnecessary long body processing
if (!feed_is_new(feed_name, feed)) {
ftotal++;
- p = decode_html_entities (p);
+ sp = decode_html_entities (p);
gchar *tmp = decode_utf8_entities(b);
g_free(b);
@@ -978,15 +980,14 @@ parse_channel_line(xmlNode *top, gchar *feed_name, char *main_date)
}
g_free(tmp);
b=(gchar *)buff;
- }
- else
+ } else
b = tmp;
}
create_feed *CF = g_new0(create_feed, 1);
/* pack all data */
CF->q = g_strdup(q);
- CF->subj = g_strdup(p);
+ CF->subj = g_strdup(sp);
CF->body = g_strdup(b);
CF->date = g_strdup(d);
CF->dcdate = g_strdup(d2);
@@ -996,7 +997,9 @@ parse_channel_line(xmlNode *top, gchar *feed_name, char *main_date)
CF->feed_fname = g_strdup(feed_name); //feed file name
CF->feed_uri = g_strdup(feed); //feed uri (uid!)
CF->category = category; //list of category feed is posted under
+ g_free(comments);
g_free(p);
+ g_free(sp);
if (q) g_free(q);
g_free(b);
if (feed) g_free(feed);
diff --git a/src/rss-config-factory.c b/src/rss-config-factory.c
index 0c27419..510e436 100644
--- a/src/rss-config-factory.c
+++ b/src/rss-config-factory.c
@@ -1956,7 +1956,7 @@ create_import_cookies_dialog (void)
g_object_set (import_file_select,
"local-only", FALSE,
NULL);
- gtk_window_set_modal (GTK_WINDOW (import_file_select), FALSE);
+ gtk_window_set_modal (GTK_WINDOW (import_file_select), TRUE);
gtk_window_set_resizable (GTK_WINDOW (import_file_select), TRUE);
gtk_window_set_destroy_with_parent (GTK_WINDOW (import_file_select), TRUE);
gtk_window_set_type_hint (GTK_WINDOW (import_file_select), GDK_WINDOW_TYPE_HINT_DIALOG);
diff --git a/src/rss.c b/src/rss.c
index 0a10245..89f70b9 100644
--- a/src/rss.c
+++ b/src/rss.c
@@ -1222,13 +1222,13 @@ gboolean
feed_new_from_xml(char *xml)
{
xmlNodePtr node;
- xmlDocPtr doc;
+ xmlDocPtr doc = NULL;
char *uid = NULL;
char *name = NULL;
char *url = NULL;
char *type = NULL;
- gboolean enabled;
- gboolean html;
+ gboolean enabled = FALSE;
+ gboolean html = FALSE;
guint del_feed=0;
guint del_days=0;
guint del_messages=0;
@@ -1314,6 +1314,7 @@ feed_new_from_xml(char *xml)
g_hash_table_insert(rf->hrttl_multiply,
g_strdup(uid),
GINT_TO_POINTER(ttl_multiply));
+ xmlFreeDoc (doc);
return TRUE;
}
@@ -1356,6 +1357,8 @@ load_gconf_feed(void)
g_free (uid);
}
+ g_slist_foreach(list, (GFunc) g_free, NULL);
+ g_slist_free(list);
}
void
@@ -2244,6 +2247,7 @@ void org_gnome_cooly_format_rss(void *ep, EMFormatHookTarget *t) //camelmimepart
//precreate stop button as we need it to control it later
GtkWidget *button2 = gtk_button_new_from_stock (GTK_STOCK_STOP);
pobj->stopbut = button2;
+ g_free (classid);
if (rf->cur_format || (feedid && is_html && rf->cur_format)) {
@@ -2275,6 +2279,7 @@ void org_gnome_cooly_format_rss(void *ep, EMFormatHookTarget *t) //camelmimepart
camel_stream_printf (t->stream,
"<object classid=%s></object></td></tr></table></div>\n",
classid);
+ g_free (classid);
goto out;
}
#endif
@@ -2332,7 +2337,6 @@ void org_gnome_cooly_format_rss(void *ep, EMFormatHookTarget *t) //camelmimepart
text_colour & 0xffffff,
buff);
- g_free(subject);
g_string_free(content, 1);
} else {
d(g_print("normal html rendering\n"));
@@ -2385,7 +2389,7 @@ pixdone: g_free(url);
xmlDocDumpMemory(src, &buff, (int*)&size);
xmlFree(src);
}
- xmlFree(wids);
+ g_free(wids);
} else
buff=(xmlChar *)tmp;
@@ -2397,6 +2401,7 @@ pixdone: g_free(url);
gchar *feed_dir = rss_component_peek_base_directory();
gchar *feed_file = g_strdup_printf("%s/%s.img", feed_dir, feedid);
+ g_free(feed_dir);
camel_stream_printf (fstream,
"<div style=\"border: solid #%06x 1px; background-color: #%06x; padding: 2px; color: #%06x;\">",
@@ -2413,6 +2418,7 @@ pixdone: g_free(url);
website,
subject);
g_object_unref(pixbuf);
+ g_free(feed_file);
goto render_body;
}
gchar *iconfile = g_build_filename (EVOLUTION_ICONDIR,
@@ -2425,7 +2431,9 @@ pixdone: g_free(url);
content_colour & 0xEDECEB & 0xffffff, text_colour & 0xffffff,
iconfile, website, subject);
g_free(iconfile);
-render_body: if (category)
+ g_free(feed_file);
+
+render_body: if (category)
camel_stream_printf(fstream,
"<div style=\"border: solid 0px; background-color: #%06x; padding: 2px; color: #%06x;\">"
"<b><font size=-1>Posted under: %s</font></b></div>",
@@ -2474,6 +2482,7 @@ render_body: if (category)
result);
g_free(result);
}
+ g_free(rfrclsid);
commstream = NULL;
} else {
fetch_comments(comments, (EMFormatHTML *)t->format);
@@ -2493,6 +2502,7 @@ render_body: if (category)
camel_object_unref(part);
camel_object_unref(fstream);
g_free(buff);
+ g_free(subject);
out: if (addr)
g_free(addr);
@@ -2583,6 +2593,7 @@ void org_gnome_cooly_folder_icon(void *ep, EMEventTargetCustomIcon *t)
gchar *ofolder = g_hash_table_lookup(rf->feed_folders, rss_folder);
gchar *key = g_hash_table_lookup(rf->hrname,
ofolder ? ofolder : rss_folder);
+ g_free(rss_folder);
if (!key)
goto normal;
@@ -2978,6 +2989,8 @@ add:
xmlFreeDoc(r->cache);
if (r->type)
g_free(r->type);
+ if (r->uids)
+ g_array_free(r->uids, TRUE);
if (r)
g_free(r);
if (content)
@@ -3218,6 +3231,7 @@ generic_finish_feed(rfMessage *msg, gpointer user_data)
g_strdup(chn_name));
save_gconf_feed();
update_ttl(md5, r->ttl);
+ //save_data = user_data;
user_data = chn_name;
}
if (g_hash_table_lookup(rf->hrdel_feed, lookup_key(user_data)))
@@ -3229,6 +3243,8 @@ generic_finish_feed(rfMessage *msg, gpointer user_data)
g_free(r->type);
if (r->version)
g_free(r->version);
+ if (r->uids)
+ g_array_free(r->uids, TRUE);
}
//ftotal+=r->total;
update_sr_message();
@@ -3268,10 +3284,10 @@ generic_finish_feed(rfMessage *msg, gpointer user_data)
}
#endif
out:
- if (user_data) {
+ if (chn_name) { //user_data
//not sure why it dies here
if (!rf->cancel && !rf->cancel_all)
- g_free(user_data);
+ g_free(chn_name); //user_data
}
return;
}
@@ -3754,6 +3770,7 @@ void
update_feed_image(RDF *r)
{
GError *err = NULL;
+ gchar *feed_file = NULL;
gchar *key = gen_md5(r->uri);
FEED_IMAGE *fi = g_new0(FEED_IMAGE, 1);
gchar *image = r->image;
@@ -3762,7 +3779,7 @@ update_feed_image(RDF *r)
gchar *feed_dir = rss_component_peek_base_directory();
if (!g_file_test(feed_dir, G_FILE_TEST_EXISTS))
g_mkdir_with_parents (feed_dir, 0755);
- gchar *feed_file = g_strdup_printf("%s/%s.img", feed_dir, key);
+ feed_file = g_strdup_printf("%s/%s.img", feed_dir, key);
d(g_print("feed_image() tmpurl:%s\n", feed_file));
g_free(feed_dir);
if (!g_file_test(feed_file, G_FILE_TEST_EXISTS)) {
@@ -3781,7 +3798,6 @@ update_feed_image(RDF *r)
&err);
if (err) {
g_print("ERR:%s\n", err->message);
- g_free(feed_file);
goto out;
}
} else {
@@ -3796,10 +3812,12 @@ update_feed_image(RDF *r)
g_strdup(r->uri), // we need to dupe key here
0,
&err); // because we might loose it if
+ g_free(server);
// feeds get deleted
}
}
-out: g_free(key);
+out: g_free(feed_file);
+ g_free(key);
}
void
@@ -4948,7 +4966,7 @@ create_mail(create_feed *CF)
g_string_append_printf(cats, "%s", (char *)p->data);
}
camel_medium_set_header(CAMEL_MEDIUM(new), "X-evolution-rss-category", cats->str);
- g_string_free(cats, FALSE);
+ g_string_free(cats, TRUE);
}
rtext = camel_data_wrapper_new ();
type = camel_content_type_new ("x-evolution", "evolution-rss-feed");
@@ -5085,8 +5103,12 @@ free_cf(create_feed *CF)
g_free(CF->encl);
g_free(CF->feed_fname);
g_free(CF->feed_uri);
- if (CF->category)
+ if (CF->comments)
+ g_free(CF->comments);
+ if (CF->category) {
+ g_list_foreach(CF->category, (GFunc)g_free, NULL);
g_list_free(CF->category);
+ }
g_free(CF);
}
@@ -5221,6 +5243,7 @@ display_folder_icon(GtkTreeStore *tree_store, gchar *key)
rss_folder = camel_store_get_folder (store, full_name, 0, NULL);
if (!rss_folder) {
g_free(full_name);
+ camel_object_unref(rss_folder);
result = FALSE;
goto out;
}
@@ -5301,10 +5324,12 @@ fetch_image(gchar *url, gchar *link)
tmpurl = g_strdup(url);
}
d(g_print("fetch_image() tmpurl:%s\n", tmpurl));
+ gchar *base_dir = rss_component_peek_base_directory();
gchar *feed_dir = g_build_path("/",
- rss_component_peek_base_directory(),
+ base_dir,
"static",
NULL);
+ g_free(base_dir);
if (!g_file_test(feed_dir, G_FILE_TEST_EXISTS))
g_mkdir_with_parents (feed_dir, 0755);
http_cache = camel_data_cache_new(feed_dir, 0, NULL);
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]