unofficial mirror of notmuch@notmuchmail.org
 help / color / mirror / code / Atom feed
* [PATCH] lib/message-file: plug three memleaks.
@ 2011-04-15 14:43 Anton Khirnov
  2011-05-09  6:46 ` Anton Khirnov
  0 siblings, 1 reply; 5+ messages in thread
From: Anton Khirnov @ 2011-04-15 14:43 UTC (permalink / raw)
  To: notmuch

---
 lib/message-file.c |    5 +++++
 1 files changed, 5 insertions(+), 0 deletions(-)

diff --git a/lib/message-file.c b/lib/message-file.c
index 7722832..b7b3286 100644
--- a/lib/message-file.c
+++ b/lib/message-file.c
@@ -341,12 +341,17 @@ notmuch_message_file_get_header (notmuch_message_file_t *message,
 		strncpy(combined_header,header_sofar,hdrsofar);
 		*(combined_header+hdrsofar) = ' ';
 		strncpy(combined_header+hdrsofar+1,decoded_value,newhdr+1);
+		free(decoded_value);
 		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);
+		decoded_value = header_sofar;
 	    }
 	}
 	/* if we found a match we can bail - unless of course we are
-- 
1.7.4.1

^ permalink raw reply related	[flat|nested] 5+ messages in thread

* Re: [PATCH] lib/message-file: plug three memleaks.
  2011-04-15 14:43 [PATCH] lib/message-file: plug three memleaks Anton Khirnov
@ 2011-05-09  6:46 ` Anton Khirnov
  2011-05-09 12:42   ` Austin Clements
  0 siblings, 1 reply; 5+ messages in thread
From: Anton Khirnov @ 2011-05-09  6:46 UTC (permalink / raw)
  To: notmuch

On Fri, 15 Apr 2011 16:43:58 +0200, Anton Khirnov <anton@khirnov.net> wrote:
> ---
>  lib/message-file.c |    5 +++++
>  1 files changed, 5 insertions(+), 0 deletions(-)
> 
> diff --git a/lib/message-file.c b/lib/message-file.c
> index 7722832..b7b3286 100644
> --- a/lib/message-file.c
> +++ b/lib/message-file.c
> @@ -341,12 +341,17 @@ notmuch_message_file_get_header (notmuch_message_file_t *message,
>  		strncpy(combined_header,header_sofar,hdrsofar);
>  		*(combined_header+hdrsofar) = ' ';
>  		strncpy(combined_header+hdrsofar+1,decoded_value,newhdr+1);
> +		free(decoded_value);
>  		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);
> +		decoded_value = header_sofar;
>  	    }
>  	}
>  	/* if we found a match we can bail - unless of course we are
> -- 
> 1.7.4.1
> 
> _______________________________________________
> notmuch mailing list
> notmuch@notmuchmail.org
> http://notmuchmail.org/mailman/listinfo/notmuch

ping

--
Anton Khirnov

^ permalink raw reply	[flat|nested] 5+ messages in thread

* Re: [PATCH] lib/message-file: plug three memleaks.
  2011-05-09  6:46 ` Anton Khirnov
@ 2011-05-09 12:42   ` Austin Clements
  2011-05-09 15:17     ` Anton Khirnov
  0 siblings, 1 reply; 5+ messages in thread
From: Austin Clements @ 2011-05-09 12:42 UTC (permalink / raw)
  To: Anton Khirnov; +Cc: notmuch

Cool.  This looks like a pretty nasty leak and I'm pretty sure your
patch is correct (though it took me a while to convince myself!).

My one nit is code style.  There should be a space between the
function name and the paren.  (Oddly, the is_received handling that
you changed is the only place in notmuch where I've seen this style
violated; but there's no sense in spreading this inconsistency.)

On Mon, May 9, 2011 at 2:46 AM, Anton Khirnov <anton@khirnov.net> wrote:
> On Fri, 15 Apr 2011 16:43:58 +0200, Anton Khirnov <anton@khirnov.net> wrote:
>> ---
>>  lib/message-file.c |    5 +++++
>>  1 files changed, 5 insertions(+), 0 deletions(-)
>>
>> diff --git a/lib/message-file.c b/lib/message-file.c
>> index 7722832..b7b3286 100644
>> --- a/lib/message-file.c
>> +++ b/lib/message-file.c
>> @@ -341,12 +341,17 @@ notmuch_message_file_get_header (notmuch_message_file_t *message,
>>               strncpy(combined_header,header_sofar,hdrsofar);
>>               *(combined_header+hdrsofar) = ' ';
>>               strncpy(combined_header+hdrsofar+1,decoded_value,newhdr+1);
>> +             free(decoded_value);
>>               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);
>> +             decoded_value = header_sofar;
>>           }
>>       }
>>       /* if we found a match we can bail - unless of course we are
>> --
>> 1.7.4.1
>>
>> _______________________________________________
>> notmuch mailing list
>> notmuch@notmuchmail.org
>> http://notmuchmail.org/mailman/listinfo/notmuch
>
> ping
>
> --
> Anton Khirnov
> _______________________________________________
> notmuch mailing list
> notmuch@notmuchmail.org
> http://notmuchmail.org/mailman/listinfo/notmuch
>

^ permalink raw reply	[flat|nested] 5+ messages in thread

* [PATCH] lib/message-file: plug three memleaks.
  2011-05-09 12:42   ` Austin Clements
@ 2011-05-09 15:17     ` Anton Khirnov
  2011-05-09 17:01       ` Jameson Graef Rollins
  0 siblings, 1 reply; 5+ messages in thread
From: Anton Khirnov @ 2011-05-09 15:17 UTC (permalink / raw)
  To: notmuch

---
 lib/message-file.c |    5 +++++
 1 files changed, 5 insertions(+), 0 deletions(-)

diff --git a/lib/message-file.c b/lib/message-file.c
index 7722832..99505c1 100644
--- a/lib/message-file.c
+++ b/lib/message-file.c
@@ -341,12 +341,17 @@ notmuch_message_file_get_header (notmuch_message_file_t *message,
 		strncpy(combined_header,header_sofar,hdrsofar);
 		*(combined_header+hdrsofar) = ' ';
 		strncpy(combined_header+hdrsofar+1,decoded_value,newhdr+1);
+		free (decoded_value);
 		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);
+		decoded_value = header_sofar;
 	    }
 	}
 	/* if we found a match we can bail - unless of course we are
-- 
1.7.5.1

^ permalink raw reply related	[flat|nested] 5+ messages in thread

* Re: [PATCH] lib/message-file: plug three memleaks.
  2011-05-09 15:17     ` Anton Khirnov
@ 2011-05-09 17:01       ` Jameson Graef Rollins
  0 siblings, 0 replies; 5+ messages in thread
From: Jameson Graef Rollins @ 2011-05-09 17:01 UTC (permalink / raw)
  To: Anton Khirnov, notmuch

[-- Attachment #1: Type: text/plain, Size: 103 bytes --]

Hey, Anton.  Thanks for identifying and fixing these.  I've pushed this
to the r-c/0.6 branch.

jamie.

[-- Attachment #2: Type: application/pgp-signature, Size: 835 bytes --]

^ permalink raw reply	[flat|nested] 5+ messages in thread

end of thread, other threads:[~2011-05-09 17:02 UTC | newest]

Thread overview: 5+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2011-04-15 14:43 [PATCH] lib/message-file: plug three memleaks Anton Khirnov
2011-05-09  6:46 ` Anton Khirnov
2011-05-09 12:42   ` Austin Clements
2011-05-09 15:17     ` Anton Khirnov
2011-05-09 17:01       ` Jameson Graef Rollins

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).