pidgin/pidgin

Fix a number of memory leaks

2021-10-27, Gary Kramlich
c357390f7c22
Parents 3713c9a8813c
Children b60171ce4589
Fix a number of memory leaks

Testing Done:
ran under valgrind, opened the conversation window and then exited and verified valgrind no longer identified the fixed leaks.

Reviewed at https://reviews.imfreedom.org/r/1107/
--- a/libpurple/protocol.c Tue Oct 26 04:07:42 2021 -0500
+++ b/libpurple/protocol.c Wed Oct 27 02:01:18 2021 -0500
@@ -237,6 +237,10 @@
g_clear_pointer(&priv->id, g_free);
g_clear_pointer(&priv->name, g_free);
g_clear_pointer(&priv->description, g_free);
+ g_clear_pointer(&priv->icon_name, g_free);
+ g_clear_pointer(&priv->icon_search_path, g_free);
+ g_clear_pointer(&priv->icon_resource_path, g_free);
+
/* I'm not sure that we can finalize a protocol plugin if an account is
* still using it.. Right now accounts don't ref protocols, but maybe
* they should?
--- a/libpurple/purplecredentialprovider.c Tue Oct 26 04:07:42 2021 -0500
+++ b/libpurple/purplecredentialprovider.c Wed Oct 27 02:01:18 2021 -0500
@@ -146,6 +146,7 @@
g_clear_pointer(&priv->id, g_free);
g_clear_pointer(&priv->name, g_free);
+ g_clear_pointer(&priv->description, g_free);
G_OBJECT_CLASS(purple_credential_provider_parent_class)->finalize(obj);
}
--- a/pidgin/gtkblist.c Tue Oct 26 04:07:42 2021 -0500
+++ b/pidgin/gtkblist.c Wed Oct 27 02:01:18 2021 -0500
@@ -6507,11 +6507,13 @@
void
pidgin_blist_update_sort_methods(void)
{
+ GtkWidget *sort_item = NULL;
GMenu *menu = NULL;
GList *l;
- if(gtkblist == NULL)
+ if(gtkblist == NULL || !PIDGIN_IS_CONTACT_LIST(gtkblist->window)) {
return;
+ }
/* create the gmenu */
menu = g_menu_new();
@@ -6520,25 +6522,25 @@
for (l = pidgin_blist_sort_methods; l; l = l->next) {
PidginBlistSortMethod *method = NULL;
GMenuItem *item = NULL;
+ GVariant *value = NULL;
gchar *action = NULL;
method = (PidginBlistSortMethod *)l->data;
-
- action = g_action_print_detailed_name("blist.sort-method",
- g_variant_new_string(method->id));
+ value = g_variant_new_string(method->id);
+
+ action = g_action_print_detailed_name("blist.sort-method", value);
item = g_menu_item_new(method->name, action);
+
g_free(action);
+ g_variant_unref(value);
g_menu_append_item(menu, item);
+ g_object_unref(item);
}
/* replace the old submenu with a new one */
- if(PIDGIN_IS_CONTACT_LIST(gtkblist->window)) {
- GtkWidget *item = NULL;
-
- item = pidgin_contact_list_get_menu_sort_item(PIDGIN_CONTACT_LIST(gtkblist->window));
- gtk_menu_item_set_submenu(GTK_MENU_ITEM(item),
- gtk_menu_new_from_model(G_MENU_MODEL(menu)));
- g_object_unref(G_OBJECT(menu));
- }
-}
+ sort_item = pidgin_contact_list_get_menu_sort_item(PIDGIN_CONTACT_LIST(gtkblist->window));
+ gtk_menu_item_set_submenu(GTK_MENU_ITEM(sort_item),
+ gtk_menu_new_from_model(G_MENU_MODEL(menu)));
+ g_object_unref(menu);
+}