diff options
author | James Booth <boothj5@gmail.com> | 2014-06-17 22:22:35 +0100 |
---|---|---|
committer | James Booth <boothj5@gmail.com> | 2014-06-17 22:22:35 +0100 |
commit | 4a485a64f9a09c1b19c59af3d03e2c2c2d62d398 (patch) | |
tree | 84f68392ac94f9d43b709b8d718922e8273358ce | |
parent | fa0be4e50ed8be0cd1fc8bb9fa2e0c1885998770 (diff) | |
download | profani-tty-4a485a64f9a09c1b19c59af3d03e2c2c2d62d398.tar.gz |
Free account_name preference on autoconnect
-rw-r--r-- | src/config/preferences.c | 2 | ||||
-rw-r--r-- | src/profanity.c | 18 |
2 files changed, 12 insertions, 8 deletions
diff --git a/src/config/preferences.c b/src/config/preferences.c index 7acd5a0d..335915aa 100644 --- a/src/config/preferences.c +++ b/src/config/preferences.c @@ -171,7 +171,7 @@ prefs_get_string(preference_t pref) char *result = g_key_file_get_string(prefs, group, key, NULL); if (result == NULL) { - return def; + return strdup(def); } else { return result; } diff --git a/src/profanity.c b/src/profanity.c index 209289e2..f99f90c3 100644 --- a/src/profanity.c +++ b/src/profanity.c @@ -72,14 +72,18 @@ prof_run(const int disable_tls, char *log_level, char *account_name) ui_update_screen(); + char *pref_connect_account = prefs_get_string(PREF_CONNECT_ACCOUNT); if (account_name != NULL) { - char *cmd = "/connect"; - snprintf(inp, sizeof(inp), "%s %s", cmd, account_name); - process_input(inp); - } else if (prefs_get_string(PREF_CONNECT_ACCOUNT) != NULL) { - char *cmd = "/connect"; - snprintf(inp, sizeof(inp), "%s %s", cmd, prefs_get_string(PREF_CONNECT_ACCOUNT)); - process_input(inp); + char *cmd = "/connect"; + snprintf(inp, sizeof(inp), "%s %s", cmd, account_name); + process_input(inp); + } else if (pref_connect_account != NULL) { + char *cmd = "/connect"; + snprintf(inp, sizeof(inp), "%s %s", cmd, pref_connect_account); + process_input(inp); + } + if (pref_connect_account != NULL) { + free(pref_connect_account); } while(cmd_result == TRUE) { |