From c72c08809b8657e6f402ea121a5ea99984baa883 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Stig=20Bj=C3=B8rlykke?= Date: Thu, 1 Jun 2017 10:57:05 +0200 Subject: [PATCH] prefs: Avoid empty elements in string lists. MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit When parsing a comma-separated string list from file we should not add an empty element if this list is empty. Otherwise we would get an empty string in when writing the file back. Change-Id: Iea5a33d20991f8c5daed6811beb8ec97b8b1dbe3 Reviewed-on: https://code.wireshark.org/review/21870 Petri-Dish: Stig Bjørlykke Tested-by: Petri Dish Buildbot Reviewed-by: Michael Mann --- epan/prefs.c | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/epan/prefs.c b/epan/prefs.c index 0c53992d4a..854fba53c8 100644 --- a/epan/prefs.c +++ b/epan/prefs.c @@ -3612,7 +3612,8 @@ prefs_get_string_list(const gchar *str) return NULL; } slstr[j] = '\0'; - sl = g_list_append(sl, slstr); + if (j > 0) + sl = g_list_append(sl, slstr); break; } if (cur_c == '"' && ! backslash) { @@ -3648,7 +3649,8 @@ prefs_get_string_list(const gchar *str) and it wasn't preceded by a backslash; it's the end of the string we were working on... */ slstr[j] = '\0'; - sl = g_list_append(sl, slstr); + if (j > 0) + sl = g_list_append(sl, slstr); /* ...and the beginning of a new string. */ state = PRE_STRING;