From a4f7932ed7dc35aa1a706d1b889c26da079963bb Mon Sep 17 00:00:00 2001 From: James Booth Date: Fri, 26 Sep 2014 00:48:48 +0100 Subject: [PATCH] Check for NULL inside autocomplete_free --- src/command/command.c | 4 +--- src/muc.c | 4 +--- src/tools/autocomplete.c | 6 ++++-- src/xmpp/bookmark.c | 4 +--- 4 files changed, 7 insertions(+), 11 deletions(-) diff --git a/src/command/command.c b/src/command/command.c index b579fdcf..bee26eff 100644 --- a/src/command/command.c +++ b/src/command/command.c @@ -1257,9 +1257,7 @@ cmd_uninit(void) autocomplete_free(autoaway_mode_ac); autocomplete_free(autoconnect_ac); autocomplete_free(theme_ac); - if (theme_load_ac != NULL) { - autocomplete_free(theme_load_ac); - } + autocomplete_free(theme_load_ac); autocomplete_free(account_ac); autocomplete_free(account_set_ac); autocomplete_free(account_clear_ac); diff --git a/src/muc.c b/src/muc.c index 623f72f5..c38064e3 100644 --- a/src/muc.c +++ b/src/muc.c @@ -594,9 +594,7 @@ _free_room(ChatRoom *room) if (room->roster) { g_hash_table_destroy(room->roster); } - if (room->nick_ac) { - autocomplete_free(room->nick_ac); - } + autocomplete_free(room->nick_ac); if (room->nick_changes) { g_hash_table_destroy(room->nick_changes); } diff --git a/src/tools/autocomplete.c b/src/tools/autocomplete.c index 5dd350e9..486fd2ba 100644 --- a/src/tools/autocomplete.c +++ b/src/tools/autocomplete.c @@ -80,8 +80,10 @@ autocomplete_reset(Autocomplete ac) void autocomplete_free(Autocomplete ac) { - autocomplete_clear(ac); - free(ac); + if (ac) { + autocomplete_clear(ac); + free(ac); + } } gint diff --git a/src/xmpp/bookmark.c b/src/xmpp/bookmark.c index b4931b8f..395bf102 100644 --- a/src/xmpp/bookmark.c +++ b/src/xmpp/bookmark.c @@ -77,9 +77,7 @@ bookmark_request(void) id = strdup("bookmark_init_request"); autojoin_count = 0; - if (bookmark_ac != NULL) { - autocomplete_free(bookmark_ac); - } + autocomplete_free(bookmark_ac); bookmark_ac = autocomplete_new(); if (bookmark_list != NULL) { g_list_free_full(bookmark_list, _bookmark_item_destroy);