[PATCH] lib: Fix memory leaks in notmuch_message_file_get_header

Carl Worth cworth at cworth.org
Mon Nov 8 09:19:49 PST 2010


On Thu,  4 Nov 2010 20:49:35 -0700, Michael Forney <mforney at mforney.org> wrote:
> When decoded_value, header_sofar, and header are unused, they should
> be freed.

Thanks for the cleanups here. Just looking over the patch it's clear
that I let some code into message-file.c without coercing the style into
what I would really prefer to see, (should use talloc more, should move
away from overly-abbreviated identifiers such as "hdrsofar", and
shouldn't have ambiguously named identifiers such as "header_sofar" and
"hdrsofar").

> +		free(decoded_value);
> +		free(header_sofar);
>  		g_hash_table_insert (message->headers, header, combined_header);
>  	    }
>  	} else {
>  	    if (header_sofar == NULL) {
>  		/* Only insert if we don't have a value for this header, yet. */
>  		g_hash_table_insert (message->headers, header, decoded_value);
> +	    } else {
> +		free(header);
> +		free(decoded_value);

But I didn't push the change yet. The above do look like memory leak
fixes as described in the commit message.

>  	if (match && !is_received)
> -	    return decoded_value;
> +	    return header_sofar == NULL ? decoded_value : header_sofar;
>      }

But this part looks like an independent bug fix that needs its own
description, (and perhaps a test case?). Could you please split the
patch into two?

Thanks,

-Carl

-- 
carl.d.worth at intel.com
-------------- next part --------------
A non-text attachment was scrubbed...
Name: not available
Type: application/pgp-signature
Size: 189 bytes
Desc: not available
URL: <http://notmuchmail.org/pipermail/notmuch/attachments/20101108/9641468b/attachment.pgp>


More information about the notmuch mailing list