1
0
mirror of https://github.com/profanity-im/profanity.git synced 2024-12-04 14:46:46 -05:00

Fix prefs_get_string mem leaks in statusbar

This commit is contained in:
Michael Vetter 2019-06-19 16:45:18 +02:00
parent 20e94beca2
commit 184f01c4ac

View File

@ -203,6 +203,7 @@ _create_tab(const int win, win_type_t wintype, char *identifier, gboolean highli
} else { } else {
tab->display_name = strdup(tab->identifier); tab->display_name = strdup(tab->identifier);
} }
prefs_free_string(pref);
} }
} }
@ -452,21 +453,27 @@ _status_bar_draw_maintext(int pos)
return; return;
} }
gboolean stop = FALSE;
if (statusbar->fulljid) { if (statusbar->fulljid) {
char *pref = prefs_get_string(PREF_STATUSBAR_SELF); char *pref = prefs_get_string(PREF_STATUSBAR_SELF);
if (g_strcmp0(pref, "off") == 0) { if (g_strcmp0(pref, "off") == 0) {
return; stop = true;
} } else if (g_strcmp0(pref, "user") == 0) {
if (g_strcmp0(pref, "user") == 0) {
Jid *jidp = jid_create(statusbar->fulljid); Jid *jidp = jid_create(statusbar->fulljid);
mvwprintw(statusbar_win, 0, pos, jidp->localpart); mvwprintw(statusbar_win, 0, pos, jidp->localpart);
jid_destroy(jidp); jid_destroy(jidp);
return; stop = true;
} } else if (g_strcmp0(pref, "barejid") == 0) {
if (g_strcmp0(pref, "barejid") == 0) {
Jid *jidp = jid_create(statusbar->fulljid); Jid *jidp = jid_create(statusbar->fulljid);
mvwprintw(statusbar_win, 0, pos, jidp->barejid); mvwprintw(statusbar_win, 0, pos, jidp->barejid);
jid_destroy(jidp); jid_destroy(jidp);
stop = true;
}
prefs_free_string(pref);
if (stop) {
return; return;
} }
mvwprintw(statusbar_win, 0, pos, statusbar->fulljid); mvwprintw(statusbar_win, 0, pos, statusbar->fulljid);
@ -556,9 +563,11 @@ _display_name(StatusBarTab *tab)
} else { } else {
fullname = strdup(tab->identifier); fullname = strdup(tab->identifier);
} }
prefs_free_string(pref);
} else if (tab->window_type == WIN_CONFIG) { } else if (tab->window_type == WIN_CONFIG) {
char *pref = prefs_get_string(PREF_STATUSBAR_ROOM); char *pref = prefs_get_string(PREF_STATUSBAR_ROOM);
GString *display_str = g_string_new(""); GString *display_str = g_string_new("");
if (g_strcmp0("room", pref) == 0) { if (g_strcmp0("room", pref) == 0) {
Jid *jidp = jid_create(tab->identifier); Jid *jidp = jid_create(tab->identifier);
g_string_append(display_str, jidp->localpart); g_string_append(display_str, jidp->localpart);
@ -566,6 +575,8 @@ _display_name(StatusBarTab *tab)
} else { } else {
g_string_append(display_str, tab->identifier); g_string_append(display_str, tab->identifier);
} }
prefs_free_string(pref);
g_string_append(display_str, " conf"); g_string_append(display_str, " conf");
char *result = strdup(display_str->str); char *result = strdup(display_str->str);
g_string_free(display_str, TRUE); g_string_free(display_str, TRUE);
@ -585,6 +596,7 @@ _display_name(StatusBarTab *tab)
} else { } else {
fullname = strdup(tab->identifier); fullname = strdup(tab->identifier);
} }
prefs_free_string(pref);
} else { } else {
fullname = strdup("window"); fullname = strdup("window");
} }