diff options
author | Michael Vetter <jubalh@iodoru.org> | 2019-06-19 16:45:18 +0200 |
---|---|---|
committer | Michael Vetter <jubalh@iodoru.org> | 2019-06-19 16:45:18 +0200 |
commit | 184f01c4ac81a19f334ca0eb810aa027c32c99ce (patch) | |
tree | dfaeb6faef7def38ee54497428b1c83359a28689 /src | |
parent | 20e94beca29f47118c14e85af22d1d6290b97c41 (diff) | |
download | profani-tty-184f01c4ac81a19f334ca0eb810aa027c32c99ce.tar.gz |
Fix prefs_get_string mem leaks in statusbar
Diffstat (limited to 'src')
-rw-r--r-- | src/ui/statusbar.c | 24 |
1 files changed, 18 insertions, 6 deletions
diff --git a/src/ui/statusbar.c b/src/ui/statusbar.c index 1fbf2156..7238b9a1 100644 --- a/src/ui/statusbar.c +++ b/src/ui/statusbar.c @@ -203,6 +203,7 @@ _create_tab(const int win, win_type_t wintype, char *identifier, gboolean highli } else { tab->display_name = strdup(tab->identifier); } + prefs_free_string(pref); } } @@ -452,21 +453,27 @@ _status_bar_draw_maintext(int pos) return; } + gboolean stop = FALSE; + if (statusbar->fulljid) { char *pref = prefs_get_string(PREF_STATUSBAR_SELF); + if (g_strcmp0(pref, "off") == 0) { - return; - } - if (g_strcmp0(pref, "user") == 0) { + stop = true; + } else if (g_strcmp0(pref, "user") == 0) { Jid *jidp = jid_create(statusbar->fulljid); mvwprintw(statusbar_win, 0, pos, jidp->localpart); jid_destroy(jidp); - return; - } - if (g_strcmp0(pref, "barejid") == 0) { + stop = true; + } else if (g_strcmp0(pref, "barejid") == 0) { Jid *jidp = jid_create(statusbar->fulljid); mvwprintw(statusbar_win, 0, pos, jidp->barejid); jid_destroy(jidp); + stop = true; + } + + prefs_free_string(pref); + if (stop) { return; } mvwprintw(statusbar_win, 0, pos, statusbar->fulljid); @@ -556,9 +563,11 @@ _display_name(StatusBarTab *tab) } else { fullname = strdup(tab->identifier); } + prefs_free_string(pref); } else if (tab->window_type == WIN_CONFIG) { char *pref = prefs_get_string(PREF_STATUSBAR_ROOM); GString *display_str = g_string_new(""); + if (g_strcmp0("room", pref) == 0) { Jid *jidp = jid_create(tab->identifier); g_string_append(display_str, jidp->localpart); @@ -566,6 +575,8 @@ _display_name(StatusBarTab *tab) } else { g_string_append(display_str, tab->identifier); } + + prefs_free_string(pref); g_string_append(display_str, " conf"); char *result = strdup(display_str->str); g_string_free(display_str, TRUE); @@ -585,6 +596,7 @@ _display_name(StatusBarTab *tab) } else { fullname = strdup(tab->identifier); } + prefs_free_string(pref); } else { fullname = strdup("window"); } |