From 184ad0a7f66f5d549fa6f1e2acaaa87592190c33 Mon Sep 17 00:00:00 2001 From: Dan Winship Date: Sun, 13 Aug 2000 20:49:28 +0000 Subject: Fix some freed-memory references * mail-format.c (add_url): Fix some freed-memory references svn path=/trunk/; revision=4806 --- mail/ChangeLog | 2 ++ mail/mail-format.c | 24 ++++++++++++------------ 2 files changed, 14 insertions(+), 12 deletions(-) (limited to 'mail') diff --git a/mail/ChangeLog b/mail/ChangeLog index b8416ff95b..3ae6f9de2a 100644 --- a/mail/ChangeLog +++ b/mail/ChangeLog @@ -1,5 +1,7 @@ 2000-08-13 Dan Winship + * mail-format.c (add_url): Fix some freed-memory references + * mail-threads.c (get_password): Don't free the prompt. It doesn't belong to you. diff --git a/mail/mail-format.c b/mail/mail-format.c index 36ce4d9b86..f9739b911e 100644 --- a/mail/mail-format.c +++ b/mail/mail-format.c @@ -109,18 +109,21 @@ free_urls (gpointer urls) g_hash_table_destroy (urls); } -static void +static char * add_url (char *url, gpointer data, MailDisplay *md) { GHashTable *urls; gpointer old_key, old_value; urls = g_datalist_get_data (md->data, "urls"); - g_return_if_fail (urls != NULL); + g_return_val_if_fail (urls != NULL, NULL); - if (g_hash_table_lookup_extended (urls, url, &old_key, &old_value)) - g_free (old_key); + if (g_hash_table_lookup_extended (urls, url, &old_key, &old_value)) { + g_free (url); + url = old_key; + } g_hash_table_insert (urls, url, data); + return url; } /** @@ -218,9 +221,7 @@ get_url_for_icon (const char *icon_name, MailDisplay *md) g_free (icon_path); url = g_strdup_printf ("x-evolution-data:%p", ba); - add_url (url, ba, md); - - return url; + return add_url (url, ba, md); } @@ -967,12 +968,12 @@ handle_text_enriched (CamelMimePart *part, const char *mime_type, g_string_free (string, TRUE); xed = g_strdup_printf ("x-evolution-data:%p", part); - add_url (xed, ba, md); - camel_object_hook_event (CAMEL_OBJECT (md->current_message), - "finalize", free_byte_array, ba); mail_html_write (md->html, md->stream, "", xed); + add_url (xed, ba, md); + camel_object_hook_event (CAMEL_OBJECT (md->current_message), + "finalize", free_byte_array, ba); return TRUE; } @@ -1523,9 +1524,8 @@ handle_via_external (CamelMimePart *part, const char *mime_type, icon = "gnome-unknown.png"; action = g_strdup_printf ("open the file in %s", app->name); url = g_strdup_printf ("x-evolution-external:%s", app->command); - add_url (url, part, md); - handle_mystery (part, md, url, icon, desc, action); + add_url (url, part, md); g_free (action); -- cgit v1.2.3