From 8531357e88dfa1bdc4657e8668dfb9856864d92e Mon Sep 17 00:00:00 2001 From: James Booth Date: Sun, 9 Aug 2015 00:20:17 +0100 Subject: [PATCH 1/5] Free strings in prefs_load --- src/config/preferences.c | 2 ++ 1 file changed, 2 insertions(+) diff --git a/src/config/preferences.c b/src/config/preferences.c index ccb1ae3a..7ae9695e 100644 --- a/src/config/preferences.c +++ b/src/config/preferences.c @@ -113,6 +113,7 @@ prefs_load(void) } else if (g_strcmp0(time, "off") == 0) { g_key_file_set_string(prefs, PREF_GROUP_UI, "time", ""); } + prefs_free_string(time); } if (g_key_file_has_key(prefs, PREF_GROUP_UI, "time.statusbar", NULL)) { char *time = g_key_file_get_string(prefs, PREF_GROUP_UI, "time.statusbar", NULL); @@ -123,6 +124,7 @@ prefs_load(void) } else if (g_strcmp0(time, "off") == 0) { g_key_file_set_string(prefs, PREF_GROUP_UI, "time.statusbar", ""); } + prefs_free_string(time); } _save_prefs(); From d944e8252ef8bd2e93edc7bb8ab8218c6bf28570 Mon Sep 17 00:00:00 2001 From: James Booth Date: Sun, 9 Aug 2015 00:21:20 +0100 Subject: [PATCH 2/5] Updated .gitignore --- .gitignore | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/.gitignore b/.gitignore index fbf0a3fb..dba938c7 100644 --- a/.gitignore +++ b/.gitignore @@ -11,6 +11,8 @@ profanity.mk profanity.project profanity.workspace compile_commands.json +.tern-port +.tern-project # autotools .libs/ @@ -56,3 +58,6 @@ gitpushall.sh # website files main_fragment.html toc_fragment.html + +# valgrind files +valgrind.out From 783342a48ce3a3db398d4aa4a0b032bddd0a9262 Mon Sep 17 00:00:00 2001 From: James Booth Date: Sun, 9 Aug 2015 00:40:37 +0100 Subject: [PATCH 3/5] Free timestamps and carbons stanzas --- src/ui/window.c | 12 +++++++++--- src/xmpp/stanza.c | 2 ++ 2 files changed, 11 insertions(+), 3 deletions(-) diff --git a/src/ui/window.c b/src/ui/window.c index 95e89849..d537c97a 100644 --- a/src/ui/window.c +++ b/src/ui/window.c @@ -907,12 +907,17 @@ void win_print(ProfWin *window, const char show_char, int pad_indent, GDateTime *timestamp, int flags, theme_item_t theme_item, const char * const from, const char * const message) { - if (timestamp == NULL) timestamp = g_date_time_new_now_local(); + if (timestamp == NULL) { + timestamp = g_date_time_new_now_local(); + } else { + g_date_time_ref(timestamp); + } buffer_push(window->layout->buffer, show_char, pad_indent, timestamp, flags, theme_item, from, message, NULL); _win_print(window, show_char, pad_indent, timestamp, flags, theme_item, from, message, NULL); // TODO: cross-reference.. this should be replaced by a real event-based system ui_input_nonblocking(TRUE); + g_date_time_unref(timestamp); } void @@ -975,7 +980,7 @@ _win_print(ProfWin *window, const char show_char, int pad_indent, GDateTime *tim gchar *date_fmt = NULL; char *time_pref = prefs_get_string(PREF_TIME); date_fmt = g_date_time_format(time, time_pref); - free(time_pref); + prefs_free_string(time_pref); assert(date_fmt != NULL); if(strlen(date_fmt) != 0){ @@ -992,7 +997,6 @@ _win_print(ProfWin *window, const char show_char, int pad_indent, GDateTime *tim wattroff(window->layout->win, theme_attrs(THEME_TIME)); } } - g_free(date_fmt); } if (strlen(from) > 0) { @@ -1049,6 +1053,8 @@ _win_print(ProfWin *window, const char show_char, int pad_indent, GDateTime *tim wattroff(window->layout->win, theme_attrs(theme_item)); } } + + g_free(date_fmt); } static void diff --git a/src/xmpp/stanza.c b/src/xmpp/stanza.c index bb32932a..acee97fb 100644 --- a/src/xmpp/stanza.c +++ b/src/xmpp/stanza.c @@ -213,6 +213,7 @@ stanza_enable_carbons(xmpp_ctx_t *ctx){ xmpp_stanza_set_ns(carbons_enable, STANZA_NS_CARBONS); xmpp_stanza_add_child(iq, carbons_enable); + xmpp_stanza_release(carbons_enable); return iq; } @@ -232,6 +233,7 @@ stanza_disable_carbons(xmpp_ctx_t *ctx){ xmpp_stanza_set_ns(carbons_disable, STANZA_NS_CARBONS); xmpp_stanza_add_child(iq, carbons_disable); + xmpp_stanza_release(carbons_disable); return iq; } From 70c0eeed1e0a2d83449dcbec6daa19f5033470e3 Mon Sep 17 00:00:00 2001 From: James Booth Date: Sun, 9 Aug 2015 00:43:00 +0100 Subject: [PATCH 4/5] Free error message in carbons handlers --- src/xmpp/iq.c | 2 ++ 1 file changed, 2 insertions(+) diff --git a/src/xmpp/iq.c b/src/xmpp/iq.c index ff684b60..db817e13 100644 --- a/src/xmpp/iq.c +++ b/src/xmpp/iq.c @@ -746,6 +746,7 @@ _enable_carbons_handler(xmpp_conn_t * const conn, xmpp_stanza_t * const stanza, char *error_message = stanza_get_error_message(stanza); cons_show_error("Server error enabling message carbons: %s", error_message); log_debug("Error enabling carbons: %s", error_message); + free(error_message); } else { log_debug("Message carbons enabled."); } @@ -761,6 +762,7 @@ _disable_carbons_handler(xmpp_conn_t * const conn, xmpp_stanza_t * const stanza, char *error_message = stanza_get_error_message(stanza); cons_show_error("Server error disabling message carbons: %s", error_message); log_debug("Error disabling carbons: %s", error_message); + free(error_message); } else { log_debug("Message carbons disabled."); } From 3b79d5aa631469cb9c5d497d68c5d9fd084dcb92 Mon Sep 17 00:00:00 2001 From: James Booth Date: Sun, 9 Aug 2015 00:54:11 +0100 Subject: [PATCH 5/5] Dereference pgp key --- src/pgp/gpg.c | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/src/pgp/gpg.c b/src/pgp/gpg.c index 724f1e9b..80aba996 100644 --- a/src/pgp/gpg.c +++ b/src/pgp/gpg.c @@ -333,12 +333,16 @@ p_gpg_sign(const char * const str, const char * const fp) error = gpgme_get_key(ctx, fp, &key, 1); if (error || key == NULL) { log_error("GPG: Failed to get key. %s %s", gpgme_strsource(error), gpgme_strerror(error)); - gpgme_release (ctx); + gpgme_release(ctx); + if (key) { + gpgme_key_unref(key); + } return NULL; } gpgme_signers_clear(ctx); error = gpgme_signers_add(ctx, key); + gpgme_key_unref(key); if (error) { log_error("GPG: Failed to load signer. %s %s", gpgme_strsource(error), gpgme_strerror(error)); gpgme_release(ctx);