Wed, 22 Mar 2023 03:21:17 -0500
Fix leaks from g_list_model_get_item
It returns a new reference, which needs to be unref'd.
Testing Done:
Compiled only, and ran tests, though these issues didn't show up in valgrind anyway.
Reviewed at https://reviews.imfreedom.org/r/2377/
--- a/libpurple/protocols/ircv3/purpleircv3messagehandlers.c Tue Mar 21 02:37:23 2023 -0500 +++ b/libpurple/protocols/ircv3/purpleircv3messagehandlers.c Wed Mar 22 03:21:17 2023 -0500 @@ -110,6 +110,7 @@ purple_contact_info_set_username(PURPLE_CONTACT_INFO(contact), source); purple_contact_manager_add(contact_manager, contact); } + g_clear_object(&contact); target = params[0]; conversation_manager = purple_conversation_manager_get_default();
--- a/libpurple/purplecontactmanager.h Tue Mar 21 02:37:23 2023 -0500 +++ b/libpurple/purplecontactmanager.h Wed Mar 22 03:21:17 2023 -0500 @@ -119,7 +119,7 @@ * Looks for a [class@Purple.Contact] that belongs to @account with a username * of @username. * - * Returns: (transfer none): The [class@Purple.Contact] if found, otherwise + * Returns: (transfer full): The [class@Purple.Contact] if found, otherwise * %NULL. * * Since: 3.0.0 @@ -134,7 +134,7 @@ * * Looks for a [class@Purple.Contact] that belongs to @account with a id of @id. * - * Returns: (transfer none): The [class@Purple.Contact] if found, otherwise + * Returns: (transfer full): The [class@Purple.Contact] if found, otherwise * %NULL. * * Since: 3.0.0
--- a/libpurple/tests/test_contact_manager.c Tue Mar 21 02:37:23 2023 -0500 +++ b/libpurple/tests/test_contact_manager.c Wed Mar 22 03:21:17 2023 -0500 @@ -292,6 +292,7 @@ contact = purple_contact_manager_find_with_id(manager, account, id); g_assert_nonnull(contact); g_assert_true(PURPLE_IS_CONTACT(contact)); + g_clear_object(&contact); /* Verify that we can find the created contact via username. */ contact = purple_contact_manager_find_with_username(manager, account,
--- a/pidgin/pidginaccounteditor.c Tue Mar 21 02:37:23 2023 -0500 +++ b/pidgin/pidginaccounteditor.c Wed Mar 22 03:21:17 2023 -0500 @@ -615,10 +615,12 @@ } model = adw_combo_row_get_model(ADW_COMBO_ROW(editor->proxy_type)); - for(guint i = 0; i < g_list_model_get_n_items(model); i++) { - GtkStringObject *obj = g_list_model_get_item(model, i); - if(purple_strequal(type, gtk_string_object_get_string(obj))) { - position = i; + for(guint index = 0; index < g_list_model_get_n_items(model); index++) { + const char *value = gtk_string_list_get_string(GTK_STRING_LIST(model), + index); + + if(purple_strequal(type, value)) { + position = index; break; } }
--- a/pidgin/pidgincontactlist.c Tue Mar 21 02:37:23 2023 -0500 +++ b/pidgin/pidgincontactlist.c Wed Mar 22 03:21:17 2023 -0500 @@ -139,6 +139,7 @@ if(!PURPLE_IS_PERSON(person)) { g_warning("we seem to have activated a zombie.. RUN!!!!!!"); + g_clear_object(&person); return; } @@ -153,6 +154,8 @@ conversation = purple_im_conversation_new(account, name); purple_conversation_manager_register(manager, conversation); } + + g_clear_object(&person); } static gboolean
--- a/pidgin/pidginprotocolchooser.c Tue Mar 21 02:37:23 2023 -0500 +++ b/pidgin/pidginprotocolchooser.c Wed Mar 22 03:21:17 2023 -0500 @@ -175,8 +175,10 @@ if(this_protocol == protocol) { position = i; + g_object_unref(this_protocol); break; } + g_object_unref(this_protocol); } }
--- a/pidgin/prefs/pidginprefs.c Tue Mar 21 02:37:23 2023 -0500 +++ b/pidgin/prefs/pidginprefs.c Wed Mar 22 03:21:17 2023 -0500 @@ -378,16 +378,15 @@ void pidgin_prefs_bind_combo_row(const gchar *key, GtkWidget *widget) { - GListModel *model = NULL; + GtkStringList *model = NULL; const char *pref_value = NULL; guint selected = GTK_INVALID_LIST_POSITION; pref_value = purple_prefs_get_string(key); - model = adw_combo_row_get_model(ADW_COMBO_ROW(widget)); + model = GTK_STRING_LIST(adw_combo_row_get_model(ADW_COMBO_ROW(widget))); - for(guint i = 0; i < g_list_model_get_n_items(model); i++) { - GtkStringObject *obj = g_list_model_get_item(model, i); - const gchar *value = gtk_string_object_get_string(obj); + for(guint i = 0; i < g_list_model_get_n_items(G_LIST_MODEL(model)); i++) { + const char *value = gtk_string_list_get_string(model, i); if (purple_strequal(pref_value, value)) { selected = i;