Tue, 04 Feb 2020 02:59:47 +0000
Merged in fbellet/pidgin/memory-leaks (pull request #633)
Memory leaks
Approved-by: Eion Robb <eionrobb@gmail.com>
Approved-by: Richard Laager <rlaager@wiktel.com>
Approved-by: Gary Kramlich <grim@reaperworld.com>
--- a/libpurple/media.c Mon Dec 30 07:08:44 2019 +0000 +++ b/libpurple/media.c Tue Feb 04 02:59:47 2020 +0000 @@ -289,6 +289,11 @@ priv->manager = NULL; } + if (priv->conference_type) { + g_free(priv->conference_type); + priv->conference_type = NULL; + } + G_OBJECT_CLASS(purple_media_parent_class)->dispose(media); } @@ -945,20 +950,16 @@ PurpleMediaCandidate *c = iter->data; if (id == purple_media_candidate_get_component_id(c)) { g_object_unref(c); - stream->active_local_candidates = - g_list_delete_link(iter, iter); - stream->active_local_candidates = g_list_prepend( + stream->active_local_candidates = g_list_delete_link( stream->active_local_candidates, - purple_media_candidate_copy( - local_candidate)); + iter); break; } } - if (iter == NULL) - stream->active_local_candidates = g_list_prepend( - stream->active_local_candidates, - purple_media_candidate_copy( - local_candidate)); + stream->active_local_candidates = g_list_prepend( + stream->active_local_candidates, + purple_media_candidate_copy( + local_candidate)); id = purple_media_candidate_get_component_id(local_candidate); @@ -967,20 +968,16 @@ PurpleMediaCandidate *c = iter->data; if (id == purple_media_candidate_get_component_id(c)) { g_object_unref(c); - stream->active_remote_candidates = - g_list_delete_link(iter, iter); - stream->active_remote_candidates = g_list_prepend( + stream->active_remote_candidates = g_list_delete_link( stream->active_remote_candidates, - purple_media_candidate_copy( - remote_candidate)); + iter); break; } } - if (iter == NULL) - stream->active_remote_candidates = g_list_prepend( - stream->active_remote_candidates, - purple_media_candidate_copy( - remote_candidate)); + stream->active_remote_candidates = g_list_prepend( + stream->active_remote_candidates, + purple_media_candidate_copy( + remote_candidate)); g_signal_emit(media, purple_media_signals[CANDIDATE_PAIR_ESTABLISHED], 0, sess_id, name, local_candidate, remote_candidate);
--- a/libpurple/media.h Mon Dec 30 07:08:44 2019 +0000 +++ b/libpurple/media.h Tue Feb 04 02:59:47 2020 +0000 @@ -110,7 +110,7 @@ * * Gets the PurpleAccount this media session is on. * - * Returns: (transfer none): The account retrieved. + * Returns: (transfer full): The account retrieved. */ PurpleAccount *purple_media_get_account(PurpleMedia *media);
--- a/libpurple/media/backend-fs2.c Mon Dec 30 07:08:44 2019 +0000 +++ b/libpurple/media/backend-fs2.c Tue Feb 04 02:59:47 2020 +0000 @@ -1441,6 +1441,7 @@ GstBus *bus; gchar *name; GKeyFile *default_props; + PurpleAccount *account; priv->conference = FS_CONFERENCE( gst_element_factory_make(priv->conference_type, NULL)); @@ -1450,12 +1451,13 @@ return FALSE; } - if (purple_account_get_silence_suppression( - purple_media_get_account(priv->media))) + account = purple_media_get_account(priv->media); + if (purple_account_get_silence_suppression(account)) priv->silence_threshold = purple_prefs_get_int( "/purple/media/audio/silence_threshold") / 100.0; else priv->silence_threshold = 0; + g_object_unref(account); pipeline = purple_media_manager_get_pipeline( purple_media_get_manager(priv->media)); @@ -1616,6 +1618,7 @@ gst_element_set_locked_state(session->src, FALSE); gst_object_unref(session->src); gst_object_unref(sinkpad); + gst_object_unref(srcpad); purple_media_manager_create_output_window(purple_media_get_manager( priv->media), priv->media, sess_id, NULL);
--- a/libpurple/mediamanager.c Mon Dec 30 07:08:44 2019 +0000 +++ b/libpurple/mediamanager.c Tue Feb 04 02:59:47 2020 +0000 @@ -429,6 +429,7 @@ #ifdef USE_VV GList *media = NULL; GList *iter; + PurpleAccount *media_account; g_return_val_if_fail(PURPLE_IS_MEDIA_MANAGER(manager), NULL); @@ -437,9 +438,11 @@ else iter = manager->priv->medias; for (; iter; iter = g_list_next(iter)) { - if (purple_media_get_account(iter->data) == account) { + media_account = purple_media_get_account(iter->data); + if (media_account == account) { media = g_list_prepend(media, iter->data); } + g_object_unref (media_account); } return media;
--- a/libpurple/network.c Mon Dec 30 07:08:44 2019 +0000 +++ b/libpurple/network.c Tue Feb 04 02:59:47 2020 +0000 @@ -681,7 +681,7 @@ turn_server, NULL, purple_network_ip_lookup_cb, - &turn_server); + &turn_ip); g_object_unref(resolver); } else { purple_debug_info("network", @@ -832,6 +832,7 @@ purple_network_uninit(void) { g_free(stun_ip); + g_free(turn_ip); g_hash_table_destroy(upnp_port_mappings); g_hash_table_destroy(nat_pmp_port_mappings);
--- a/libpurple/plugins.c Mon Dec 30 07:08:44 2019 +0000 +++ b/libpurple/plugins.c Tue Feb 04 02:59:47 2020 +0000 @@ -94,13 +94,15 @@ priv = purple_plugin_info_get_instance_private(info); if (priv->error) { + gchar *filename = gplugin_plugin_get_filename(plugin); purple_debug_error("plugins", "Failed to load plugin %s: %s", - gplugin_plugin_get_filename(plugin), + filename, priv->error); g_set_error(error, PURPLE_PLUGINS_DOMAIN, 0, "Plugin is not loadable: %s", priv->error); + g_free(filename); return FALSE; } @@ -111,6 +113,7 @@ plugin_loaded_cb(GObject *manager, PurplePlugin *plugin) { PurplePluginInfo *info; + gchar *filename; g_return_if_fail(PURPLE_IS_PLUGIN(plugin)); @@ -119,11 +122,12 @@ return; /* a GPlugin internal plugin */ loaded_plugins = g_list_prepend(loaded_plugins, plugin); + filename = gplugin_plugin_get_filename(plugin); - purple_debug_info("plugins", "Loaded plugin %s\n", - gplugin_plugin_get_filename(plugin)); + purple_debug_info("plugins", "Loaded plugin %s\n", filename); purple_signal_emit(purple_plugins_get_handle(), "plugin-load", plugin); + g_free(filename); } static gboolean @@ -131,13 +135,16 @@ gpointer data) { PurplePluginInfo *info; + gchar *filename; g_return_val_if_fail(PURPLE_IS_PLUGIN(plugin), FALSE); info = purple_plugin_get_info(plugin); if (info) { + filename = gplugin_plugin_get_filename(plugin); purple_debug_info("plugins", "Unloading plugin %s\n", - gplugin_plugin_get_filename(plugin)); + filename); + g_free(filename); } return TRUE; @@ -178,6 +185,7 @@ purple_plugin_load(PurplePlugin *plugin, GError **error) { GError *err = NULL; + gchar *filename; g_return_val_if_fail(plugin != NULL, FALSE); @@ -185,14 +193,15 @@ return TRUE; if (!gplugin_manager_load_plugin(plugin, &err)) { + filename = gplugin_plugin_get_filename(plugin); purple_debug_error("plugins", "Failed to load plugin %s: %s", - gplugin_plugin_get_filename(plugin), + filename, err ? err->message : "Unknown reason"); if (error) *error = g_error_copy(err); g_error_free(err); - + g_free(filename); return FALSE; } @@ -203,6 +212,7 @@ purple_plugin_unload(PurplePlugin *plugin, GError **error) { GError *err = NULL; + gchar *filename; g_return_val_if_fail(plugin != NULL, FALSE); @@ -210,13 +220,15 @@ return TRUE; if (!gplugin_manager_unload_plugin(plugin, &err)) { + filename = gplugin_plugin_get_filename(plugin); purple_debug_error("plugins", "Failed to unload plugin %s: %s", - gplugin_plugin_get_filename(plugin), + filename, err ? err->message : "Unknown reason"); if (error) *error = g_error_copy(err); g_error_free(err); + g_free(filename); return FALSE; } @@ -669,9 +681,11 @@ if (!priv->unloaded && purple_plugin_info_get_flags(info) & PURPLE_PLUGIN_INFO_FLAGS_AUTO_LOAD) { + gchar *filename = gplugin_plugin_get_filename(plugin); purple_debug_info("plugins", "Auto-loading plugin %s\n", - gplugin_plugin_get_filename(plugin)); + filename); purple_plugin_load(plugin, NULL); + g_free(filename); } } @@ -710,12 +724,14 @@ for (l = plugins; l != NULL; l = l->next) { PurplePlugin *plugin = PURPLE_PLUGIN(l->data); + gchar *plugin_filename = gplugin_plugin_get_filename(plugin); - if (purple_strequal(gplugin_plugin_get_filename(plugin), - filename)) { + if (purple_strequal(plugin_filename, filename)) { g_list_free(plugins); + g_free(plugin_filename); return plugin; } + g_free(plugin_filename); } g_list_free(plugins); @@ -747,7 +763,7 @@ } purple_prefs_set_path_list(key, files); - g_list_free(files); + g_list_free_full(files, g_free); } void
--- a/libpurple/plugins/purple-toast.c Mon Dec 30 07:08:44 2019 +0000 +++ b/libpurple/plugins/purple-toast.c Tue Feb 04 02:59:47 2020 +0000 @@ -206,6 +206,7 @@ "abi-version", PURPLE_ABI_VERSION, "name", "Purple Toast", "version", "0.0.1", + "summary", "Toast notifications", "authors", authors, NULL );
--- a/libpurple/protocols/jabber/caps.c Mon Dec 30 07:08:44 2019 +0000 +++ b/libpurple/protocols/jabber/caps.c Tue Feb 04 02:59:47 2020 +0000 @@ -902,6 +902,7 @@ ret = g_base64_encode(checksum, checksum_size); g_free(checksum); + g_checksum_free(hash); return ret; }
--- a/libpurple/protocols/jabber/jingle/iceudp.c Mon Dec 30 07:08:44 2019 +0000 +++ b/libpurple/protocols/jabber/jingle/iceudp.c Tue Feb 04 02:59:47 2020 +0000 @@ -70,6 +70,7 @@ gchar *ip; gchar *username; gchar *password; + gchar *foundation; JingleIceUdpCandidate *iceudp_candidate; GList *iter; @@ -77,11 +78,11 @@ username = purple_media_candidate_get_username(candidate); password = purple_media_candidate_get_password(candidate); type = purple_media_candidate_get_candidate_type(candidate); + foundation = purple_media_candidate_get_foundation(candidate); iceudp_candidate = jingle_iceudp_candidate_new(id, purple_media_candidate_get_component_id(candidate), - purple_media_candidate_get_foundation(candidate), - generation, ip, 0, + foundation, generation, ip, 0, purple_media_candidate_get_port(candidate), purple_media_candidate_get_priority(candidate), "udp", type == PURPLE_MEDIA_CANDIDATE_TYPE_HOST ? "host" : @@ -94,6 +95,7 @@ g_free(password); g_free(username); + g_free(foundation); g_free(ip); for (iter = priv->local_candidates; iter; iter = g_list_next(iter)) { @@ -364,12 +366,22 @@ } static void -jingle_iceudp_finalize (GObject *iceudp) +jingle_iceudp_candidate_free(JingleIceUdpCandidate *candidate); + +static void +jingle_iceudp_finalize (GObject *object) { -/* JingleIceUdpPrivate *priv = JINGLE_ICEUDP_GET_PRIVATE(iceudp); */ + JingleIceUdp *iceudp = JINGLE_ICEUDP(object); + JingleIceUdpPrivate *priv = jingle_iceudp_get_instance_private(iceudp); + purple_debug_info("jingle","jingle_iceudp_finalize\n"); - G_OBJECT_CLASS(jingle_iceudp_parent_class)->finalize(iceudp); + g_list_free_full(priv->local_candidates, + (GDestroyNotify)jingle_iceudp_candidate_free); + g_list_free_full(priv->remote_candidates, + (GDestroyNotify)jingle_iceudp_candidate_free); + + G_OBJECT_CLASS(jingle_iceudp_parent_class)->finalize(object); } static void @@ -444,6 +456,7 @@ g_free(candidate->username); g_free(candidate->password); + g_free(candidate); } G_DEFINE_BOXED_TYPE(JingleIceUdpCandidate, jingle_iceudp_candidate,
--- a/libpurple/protocols/jabber/jingle/jingle.c Mon Dec 30 07:08:44 2019 +0000 +++ b/libpurple/protocols/jabber/jingle/jingle.c Tue Feb 04 02:59:47 2020 +0000 @@ -433,6 +433,7 @@ if (js->sessions) { GList *list = g_hash_table_get_values(js->sessions); g_list_free_full(list, g_object_unref); + g_clear_pointer(&js->sessions, g_hash_table_unref); } }
--- a/libpurple/protocols/jabber/jingle/rtp.c Mon Dec 30 07:08:44 2019 +0000 +++ b/libpurple/protocols/jabber/jingle/rtp.c Tue Feb 04 02:59:47 2020 +0000 @@ -121,7 +121,7 @@ session, jingle_transport_get_transport_type(oldtransport), 0, candidates); - g_list_free(candidates); + purple_media_candidate_list_free(candidates); g_object_unref(oldtransport); jingle_content_set_pending_transport(content, transport); @@ -578,6 +578,9 @@ g_free(remote_jid); g_free(name); g_object_unref(session); + g_object_unref(transport); + purple_media_candidate_list_free(candidates); + purple_media_codec_list_free(codecs); break; } case JINGLE_SESSION_TERMINATE: { @@ -607,6 +610,8 @@ g_free(remote_jid); g_free(name); g_object_unref(session); + g_object_unref(transport); + purple_media_candidate_list_free(candidates); break; } case JINGLE_DESCRIPTION_INFO: {
--- a/libpurple/queuedoutputstream.c Mon Dec 30 07:08:44 2019 +0000 +++ b/libpurple/queuedoutputstream.c Tue Feb 04 02:59:47 2020 +0000 @@ -216,6 +216,7 @@ return; } + g_clear_error (&error); priv->pending_queued = TRUE; if (set_pending) {
--- a/pidgin/gtkblist.c Mon Dec 30 07:08:44 2019 +0000 +++ b/pidgin/gtkblist.c Tue Feb 04 02:59:47 2020 +0000 @@ -7374,7 +7374,6 @@ pidgin_blist_update(NULL, PURPLE_BLIST_NODE(buddy)); - g_object_unref(buddy); return FALSE; } @@ -7395,8 +7394,10 @@ g_source_remove(gtknode->recent_signonoff_timer); g_object_ref(buddy); - gtknode->recent_signonoff_timer = g_timeout_add_seconds(10, - (GSourceFunc)buddy_signonoff_timeout_cb, buddy); + gtknode->recent_signonoff_timer = g_timeout_add_seconds_full( + G_PRIORITY_DEFAULT, 10, + (GSourceFunc)buddy_signonoff_timeout_cb, + buddy, g_object_unref); } void
--- a/pidgin/gtkmedia.c Mon Dec 30 07:08:44 2019 +0000 +++ b/pidgin/gtkmedia.c Tue Feb 04 02:59:47 2020 +0000 @@ -491,6 +491,11 @@ gtkmedia->priv->remote_videos = NULL; } + if (gtkmedia->priv->screenname) { + g_free(gtkmedia->priv->screenname); + gtkmedia->priv->screenname = NULL; + } + G_OBJECT_CLASS(pidgin_media_parent_class)->dispose(media); } @@ -506,11 +511,13 @@ static void pidgin_media_emit_message(PidginMedia *gtkmedia, const char *msg) { + PurpleAccount *account = purple_media_get_account( + gtkmedia->priv->media); PurpleConversation *conv = purple_conversations_find_with_account( - gtkmedia->priv->screenname, - purple_media_get_account(gtkmedia->priv->media)); + gtkmedia->priv->screenname, account); if (conv != NULL) purple_conversation_write_system_message(conv, msg, 0); + g_object_unref(account); } typedef struct @@ -578,9 +585,10 @@ static void pidgin_media_error_cb(PidginMedia *media, const char *error, PidginMedia *gtkmedia) { + PurpleAccount *account = purple_media_get_account( + gtkmedia->priv->media); PurpleConversation *conv = purple_conversations_find_with_account( - gtkmedia->priv->screenname, - purple_media_get_account(gtkmedia->priv->media)); + gtkmedia->priv->screenname, account); if (conv != NULL) { purple_conversation_write_system_message( conv, error, PURPLE_MESSAGE_ERROR); @@ -591,6 +599,7 @@ gtk_statusbar_push(GTK_STATUSBAR(gtkmedia->priv->statusbar), 0, error); + g_object_unref(account); } static void @@ -649,6 +658,7 @@ } pidgin_media_emit_message(gtkmedia, message); g_free(message); + g_object_unref(account); return FALSE; }
--- a/pidgin/gtkrequest.c Mon Dec 30 07:08:44 2019 +0000 +++ b/pidgin/gtkrequest.c Tue Feb 04 02:59:47 2020 +0000 @@ -2492,7 +2492,7 @@ par = gtk_window_get_transient_for(win); it = gtk_window_list_toplevels(); - for (it = g_list_first(it); it != NULL; it = g_list_next(it)) { + for (it = g_list_first(it); it != NULL; it = g_list_delete_link(it, it)) { GtkWindow *child = GTK_WINDOW(it->data); if (gtk_window_get_transient_for(child) != win) continue;