From 3ae395b7c893fe8e535708ae0a46295d52c7f978 Mon Sep 17 00:00:00 2001 From: Ricardo Mones Date: Mon, 28 Oct 2013 09:39:35 +0100 Subject: [PATCH] Fix segfault for addresses without name part Thanks Paul for reporting on irc ;-) --- src/compose.c | 22 ++++++++++++---------- 1 file changed, 12 insertions(+), 10 deletions(-) diff --git a/src/compose.c b/src/compose.c index 1c8b05b77..2021d9fbf 100644 --- a/src/compose.c +++ b/src/compose.c @@ -6138,16 +6138,18 @@ static gchar *compose_quote_list_of_addresses(gchar *str) for (item = list; item != NULL; item = item->next) { gchar *spec = item->data; gchar *endofname = strstr(spec, " <"); - *endofname = '\0'; - QUOTE_IF_REQUIRED_NORMAL(qname, spec, return NULL); - *endofname = ' '; - if (*qname != *spec) { /* has been quoted, compute new */ - gchar *addr = g_strdup(endofname); - gchar *name = g_strdup(qname); - faddr = g_strconcat(name, addr, NULL); - g_free(name); - g_free(addr); - debug_print("new auto-quoted address: '%s'", faddr); + if (endofname != NULL) { + *endofname = '\0'; + QUOTE_IF_REQUIRED_NORMAL(qname, spec, return NULL); + *endofname = ' '; + if (*qname != *spec) { /* has been quoted, compute new */ + gchar *addr = g_strdup(endofname); + gchar *name = g_strdup(qname); + faddr = g_strconcat(name, addr, NULL); + g_free(name); + g_free(addr); + debug_print("new auto-quoted address: '%s'", faddr); + } } if (result == NULL) result = g_strdup((faddr != NULL)? faddr: spec); -- 2.25.1