summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorStig Bjørlykke <stig@bjorlykke.org>2017-06-01 10:57:05 +0200
committerMichael Mann <mmann78@netscape.net>2017-06-01 11:30:25 +0000
commitc72c08809b8657e6f402ea121a5ea99984baa883 (patch)
treea1af03147bd8c567231469c38a6b78348333a820
parent561be48f40295cc3d52376a33d017f10bd41eef0 (diff)
downloadwireshark-c72c08809b8657e6f402ea121a5ea99984baa883.tar.gz
prefs: Avoid empty elements in string lists.
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 <stig@bjorlykke.org> Tested-by: Petri Dish Buildbot <buildbot-no-reply@wireshark.org> Reviewed-by: Michael Mann <mmann78@netscape.net>
-rw-r--r--epan/prefs.c6
1 files 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;