diff options
author | P. J. McDermott <pj@pehjota.net> | 2018-09-30 17:46:27 (EDT) |
---|---|---|
committer | P. J. McDermott <pj@pehjota.net> | 2018-09-30 17:46:27 (EDT) |
commit | 251e8dda7296f3516c017f6dad21a1d3fa2f4baf (patch) | |
tree | 7bda4f3b5e1a067d17b794f96c11eaef05043db7 | |
parent | 4fbc940fd0ed6799c60448d939cc61d71655b114 (diff) | |
download | marquee-251e8dda7296f3516c017f6dad21a1d3fa2f4baf.zip marquee-251e8dda7296f3516c017f6dad21a1d3fa2f4baf.tar.gz marquee-251e8dda7296f3516c017f6dad21a1d3fa2f4baf.tar.bz2 |
MqTabLabel: Free scrolled title and markup memory
-rw-r--r-- | src/tab-label.c | 11 |
1 files changed, 11 insertions, 0 deletions
diff --git a/src/tab-label.c b/src/tab-label.c index cd9f00d..3ea33d0 100644 --- a/src/tab-label.c +++ b/src/tab-label.c @@ -186,6 +186,8 @@ set_title(MqTabLabel *tab_label, const gchar *title) g_free(tab_label->title); tab_label->title = g_strdup(title); if (tab_label->scrolling) { + g_free(tab_label->scrolled_title); + g_free(tab_label->scrolled_markup); tab_label->scrolled_title = g_strdup_printf("%s ", title); tab_label->scrolled_markup = g_markup_printf_escaped(SCROLLED_TITLE_FMT, @@ -398,6 +400,12 @@ mq_tab_label_set_position(MqTabLabel *tab_label, guint position) void mq_tab_label_begin_scrolling(MqTabLabel *tab_label) { + if (tab_label->scrolling) { + /* Avoid leaking tab_label->scrolled_title and + * tab_label->scrolled_markup. */ + return; + } + tab_label->scrolling = TRUE; tab_label->scrolled_title = g_strdup_printf("%s ", tab_label->title); tab_label->scrolled_markup = g_markup_printf_escaped(SCROLLED_TITLE_FMT, @@ -408,6 +416,8 @@ void mq_tab_label_end_scrolling(MqTabLabel *tab_label) { tab_label->scrolling = FALSE; + g_free(tab_label->scrolled_title); + g_free(tab_label->scrolled_markup); update_label(tab_label); } @@ -436,6 +446,7 @@ mq_tab_label_scroll(MqTabLabel *tab_label) tab_label->scrolled_title[j] = c[i]; } + g_free(tab_label->scrolled_markup); tab_label->scrolled_markup = g_markup_printf_escaped(SCROLLED_TITLE_FMT, tab_label->scrolled_title); update_label(tab_label); |