[PATCH] lib/message-file: plug three memleaks.
--- 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
Problem with "Unexpected output" messages
On Wed, 06 Apr 2011 20:23:17 +0100, Andreas Amann wrote: > > since commit 44d3c57e (emacs: Display any unexpected output from notmuch > search) I see a number of messages of the form > > Error: Unexpected output from notmuch search: > thread: > > after notmuch-search in emacs. FWIW, the patch below solves the problem for me. Andreas - [PATCH] Sanitize "Subject:" and "Author:" fields to not contain control characters in notmuch-search When a Subject field contained encoded CRLF sequences, these sequences would appear unfiltered in the output of notmuch search. This confused the notmuch emacs interface leading to "Unexpected Output" messages. This is now fixed by replacing all characters with ASCII code less than 32 with a question mark. --- notmuch-search.c | 22 -- 1 files changed, 20 insertions(+), 2 deletions(-) diff --git a/notmuch-search.c b/notmuch-search.c index 8b90121..fc13e60 100644 --- a/notmuch-search.c +++ b/notmuch-search.c @@ -108,6 +108,20 @@ format_item_id_text (unused (const void *ctx), printf ("%s%s", item_type, item_id); } +static char * +sanitize_string(const void *ctx, const char *str) +{ +char *out, *loop; + +loop = out = talloc_strdup (ctx, str); + +for(;*loop;loop++){ + if ((unsigned char)(*loop) < 32) + *loop = '?'; +} +return out; +} + static void format_thread_text (const void *ctx, const char *thread_id, @@ -117,13 +131,17 @@ format_thread_text (const void *ctx, const char *authors, const char *subject) { +void *ctx_quote = talloc_new (ctx); + printf ("thread:%s %12s [%d/%d] %s; %s", thread_id, notmuch_time_relative_date (ctx, date), matched, total, - authors, - subject); + sanitize_string(ctx_quote, authors), + sanitize_string(ctx_quote, subject)); + +talloc_free (ctx_quote); } static void -- 1.7.4.1
[PATCH] lib/message-file: plug three memleaks.
--- 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
Re: Problem with "Unexpected output" messages
On Wed, 06 Apr 2011 20:23:17 +0100, Andreas Amann wrote: > > since commit 44d3c57e (emacs: Display any unexpected output from notmuch > search) I see a number of messages of the form > > Error: Unexpected output from notmuch search: > thread: > > after notmuch-search in emacs. FWIW, the patch below solves the problem for me. Andreas - [PATCH] Sanitize "Subject:" and "Author:" fields to not contain control characters in notmuch-search When a Subject field contained encoded CRLF sequences, these sequences would appear unfiltered in the output of notmuch search. This confused the notmuch emacs interface leading to "Unexpected Output" messages. This is now fixed by replacing all characters with ASCII code less than 32 with a question mark. --- notmuch-search.c | 22 -- 1 files changed, 20 insertions(+), 2 deletions(-) diff --git a/notmuch-search.c b/notmuch-search.c index 8b90121..fc13e60 100644 --- a/notmuch-search.c +++ b/notmuch-search.c @@ -108,6 +108,20 @@ format_item_id_text (unused (const void *ctx), printf ("%s%s", item_type, item_id); } +static char * +sanitize_string(const void *ctx, const char *str) +{ +char *out, *loop; + +loop = out = talloc_strdup (ctx, str); + +for(;*loop;loop++){ + if ((unsigned char)(*loop) < 32) + *loop = '?'; +} +return out; +} + static void format_thread_text (const void *ctx, const char *thread_id, @@ -117,13 +131,17 @@ format_thread_text (const void *ctx, const char *authors, const char *subject) { +void *ctx_quote = talloc_new (ctx); + printf ("thread:%s %12s [%d/%d] %s; %s", thread_id, notmuch_time_relative_date (ctx, date), matched, total, - authors, - subject); + sanitize_string(ctx_quote, authors), + sanitize_string(ctx_quote, subject)); + +talloc_free (ctx_quote); } static void -- 1.7.4.1 ___ notmuch mailing list notmuch@notmuchmail.org http://notmuchmail.org/mailman/listinfo/notmuch