[PATCH 2/2] Release memory allocated by internet_address_list_parse_string()

Tomi Ollila tomi.ollila at iki.fi
Fri Dec 9 05:53:53 PST 2011


g_object_unref() releases the memory of the InternetAddressList object
returned by internet_address_list_parse_string() -- when last (only)
reference is released, internet_address_list_finalize() will do cleanup.
---
When reviewing, see also gmime-2.4.25/gmime/internet-address.c (or older)
I tested this patch by entering:  notmuch show --format=mbox '*' | wc

Note that this fixes one potential memory leak only in case --format=mbox
as _extract_email_address is called only there.

 notmuch-show.c |    3 ++-
 1 files changed, 2 insertions(+), 1 deletions(-)

diff --git a/notmuch-show.c b/notmuch-show.c
index c27ef6a..db02891 100644
--- a/notmuch-show.c
+++ b/notmuch-show.c
@@ -259,7 +259,8 @@ _extract_email_address (const void *ctx, const char *from)
     email = talloc_strdup (ctx, email);
 
   DONE:
-    /* XXX: How to free addresses here? */
+    g_object_unref(addresses);
+
     return email;
    }
 
-- 
1.7.7.3


More information about the notmuch mailing list