From ba223798d3f0116d242e0010063c81f87eecf9f5 Mon Sep 17 00:00:00 2001 From: "Lubomir I. Ivanov" Date: Sat, 22 Dec 2012 20:19:51 -0800 Subject: Free some nickname related memory in gtk-gui.c init_ui(): We add the char pointer "conf_copy" and free it afterwards, since once "next_token" is changed it no longer points to the allocated heap location the mapper returned. [Dirk Hohndel: original patch rewritten to have better variable names and to match the recent changes to this code] Signed-off-by: Lubomir I. Ivanov Signed-off-by: Dirk Hohndel --- gtk-gui.c | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/gtk-gui.c b/gtk-gui.c index 4da70f56f..3edb3f667 100644 --- a/gtk-gui.c +++ b/gtk-gui.c @@ -1205,10 +1205,10 @@ void init_ui(int *argcp, char ***argvp) conf_value = subsurface_get_conf("dc_nicknames", PREF_STRING); nicknamestring = strdup(""); if (conf_value) { - char *next_token, *nickname, *model; + char *next_token, *nickname, *model, *conf_copy; uint32_t deviceid; int len; - next_token = strdup(conf_value); + next_token = conf_copy = strdup(conf_value); len = strlen(next_token); while ((next_token = g_utf8_strchr(next_token, len, '{')) != NULL) { /* replace the '{' so we keep looking in case any test fails */ @@ -1246,7 +1246,7 @@ void init_ui(int *argcp, char ***argvp) }; } free((void *)conf_value); - free(next_token); + free(conf_copy); } error_info_bar = NULL; win = gtk_window_new(GTK_WINDOW_TOPLEVEL); -- cgit v1.2.3-70-g09d2