From: Tomi Ollila <tomi.ollila@iki.fi>
To: notmuch@notmuchmail.org
Subject: Re: [PATCH] Release memory allocated by internet_address_list_parse_string()
Date: Wed, 07 Dec 2011 23:29:52 +0200 [thread overview]
Message-ID: <yf61usgul2n.fsf@taco2.nixu.fi> (raw)
In-Reply-To: <yf61usgywbk.fsf@taco2.nixu.fi>
On Wed, 07 Dec 2011 22:13:19 +0200, Tomi Ollila <tomi.ollila@iki.fi> wrote:
> 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.
There is at least one bug here -- I failed to check whether addresses
is non-NULL before attempting to g_object_unref (). So please ignore
that when reviewing whether g_object_unref() is the correct action here.
I provide a new patch when I know whether re-check or separate the
NULL test in the beginning of _extract_email_address().
> notmuch-show.c | 2 +-
> 1 files changed, 1 insertions(+), 1 deletions(-)
>
> diff --git a/notmuch-show.c b/notmuch-show.c
> index 603992a..3abfa07 100644
> --- a/notmuch-show.c
> +++ b/notmuch-show.c
> @@ -255,7 +255,7 @@ _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
Tomi
next prev parent reply other threads:[~2011-12-07 21:29 UTC|newest]
Thread overview: 7+ messages / expand[flat|nested] mbox.gz Atom feed top
2011-12-07 20:13 [PATCH] Release memory allocated by internet_address_list_parse_string() Tomi Ollila
2011-12-07 21:29 ` Tomi Ollila [this message]
2011-12-09 13:52 ` [Patch 1/2] separate handling when addresses == NULL Tomi Ollila
2011-12-09 15:57 ` Austin Clements
2011-12-09 13:53 ` [PATCH 2/2] Release memory allocated by internet_address_list_parse_string() Tomi Ollila
2011-12-10 10:18 ` [PATCH v3] " Tomi Ollila
2011-12-11 14:49 ` David Bremner
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
List information: https://notmuchmail.org/
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=yf61usgul2n.fsf@taco2.nixu.fi \
--to=tomi.ollila@iki.fi \
--cc=notmuch@notmuchmail.org \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
Code repositories for project(s) associated with this public inbox
https://yhetil.org/notmuch.git/
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).