diff options
author | Mikael Kanstrup <mikael.kanstrup@gmail.com> | 2017-09-14 10:19:12 +0200 |
---|---|---|
committer | Anders Broman <a.broman58@gmail.com> | 2017-09-19 06:43:28 +0000 |
commit | 16fc1903037dead72d5f6ff1457552d23b4a423f (patch) | |
tree | f9c4f523b57483b010014a80c2dda0160ae9f39e | |
parent | 6bc4de9a2674f86e70bb5fdff48e861f3f5e48c5 (diff) |
prefs: Fix leak when parsing empty pref string
Fix minor leak. When parsing preference string lists and preference
is empty a buffer is allocated to hold the string but is then never
inserted into the string list as it is empty. This causes a minor leak
as no reference is kept to allocated buffer and won't be freed by
corresponding clear string list function call.
Bug: 14071
Change-Id: I1edcc77095c0f430e03a49491e5281730fbceb95
Reviewed-on: https://code.wireshark.org/review/23598
Reviewed-by: Michael Mann <mmann78@netscape.net>
Petri-Dish: Michael Mann <mmann78@netscape.net>
Tested-by: Petri Dish Buildbot <buildbot-no-reply@wireshark.org>
Reviewed-by: Anders Broman <a.broman58@gmail.com>
-rw-r--r-- | epan/prefs.c | 7 |
1 files changed, 5 insertions, 2 deletions
diff --git a/epan/prefs.c b/epan/prefs.c index 00af81f1ca..f29601b66e 100644 --- a/epan/prefs.c +++ b/epan/prefs.c @@ -3636,6 +3636,8 @@ prefs_get_string_list(const gchar *str) slstr[j] = '\0'; if (j > 0) sl = g_list_append(sl, slstr); + else + g_free(slstr); break; } if (cur_c == '"' && ! backslash) { @@ -3671,12 +3673,13 @@ 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'; - if (j > 0) + if (j > 0) { sl = g_list_append(sl, slstr); + slstr = (gchar *) g_malloc(sizeof(gchar) * COL_MAX_LEN); + } /* ...and the beginning of a new string. */ state = PRE_STRING; - slstr = (gchar *) g_malloc(sizeof(gchar) * COL_MAX_LEN); j = 0; } else if (!g_ascii_isspace(cur_c) || state != PRE_STRING) { /* Either this isn't a white-space character, or we've started a |