about summary refs log tree commit diff stats
path: root/src
diff options
context:
space:
mode:
authorSimon Effenberg <savar@schuldeigen.de>2015-01-14 08:15:15 +0100
committerSimon Effenberg <savar@schuldeigen.de>2015-01-14 08:18:52 +0100
commit6f55d06e2b1ddf4e82f5f6cb14365b82880fbf5d (patch)
tree3be9b88dc4cefc9c5f432ce376e4132c1ddfd293 /src
parente19d57779f9a0d89f47b6bbdcdd20fbdc5083e6a (diff)
downloadprofani-tty-6f55d06e2b1ddf4e82f5f6cb14365b82880fbf5d.tar.gz
fix the fix (memory leak)
the "fix a potential leak" from Will Song is not fully addressing the
issue.. so now the "def" variable should definitely being freed
Diffstat (limited to 'src')
-rw-r--r--src/command/commands.c4
1 files changed, 3 insertions, 1 deletions
diff --git a/src/command/commands.c b/src/command/commands.c
index 012d5fb7..9fd6eed4 100644
--- a/src/command/commands.c
+++ b/src/command/commands.c
@@ -93,7 +93,6 @@ cmd_connect(gchar **args, struct cmd_help_t help)
     } else {
         gchar *opt_keys[] = { "server", "port", NULL };
         gboolean parsed;
-        char *def = prefs_get_string(PREF_DEFAULT_ACCOUNT);
 
         GHashTable *options = parse_options(&args[args[0] ? 1 : 0], opt_keys, &parsed);
         if (!parsed) {
@@ -115,16 +114,19 @@ cmd_connect(gchar **args, struct cmd_help_t help)
         }
 
         char *user = args[0];
+        char *def = prefs_get_string(PREF_DEFAULT_ACCOUNT);
         if(!user){
             if(def){
                 user = def;
                 cons_show("Using default account %s.", user);
             } else {
                 cons_show("No default account.");
+                g_free(def);
                 return TRUE;
             }
         }
         g_free(def);
+        def = NULL;
 
         char *lower = g_utf8_strdown(user, -1);
         char *jid;