pidgin/pidgin

fix various memory leaks
memory-leaks
19 months ago, Fabrice Bellet
d253f767f6cc
Parents 905872c9dd7a
Children 03bafaff77dd
fix various memory leaks
--- a/libpurple/buddylist.c Tue Dec 10 04:43:23 2019 +0000
+++ b/libpurple/buddylist.c Mon Oct 21 16:31:36 2019 +0200
@@ -804,6 +804,9 @@
{
PurpleBuddyListClass *klass = NULL;
+ if (!purplebuddylist)
+ return NULL;
+
g_return_if_fail(PURPLE_IS_BUDDY_LIST(purplebuddylist));
klass = PURPLE_BUDDY_LIST_GET_CLASS(purplebuddylist);
--- a/libpurple/media.c Tue Dec 10 04:43:23 2019 +0000
+++ b/libpurple/media.c Mon Oct 21 16:31:36 2019 +0200
@@ -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);
}
--- a/libpurple/media/backend-fs2.c Tue Dec 10 04:43:23 2019 +0000
+++ b/libpurple/media/backend-fs2.c Mon Oct 21 16:31:36 2019 +0200
@@ -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 Tue Dec 10 04:43:23 2019 +0000
+++ b/libpurple/mediamanager.c Mon Oct 21 16:31:36 2019 +0200
@@ -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 Tue Dec 10 04:43:23 2019 +0000
+++ b/libpurple/network.c Mon Oct 21 16:31:36 2019 +0200
@@ -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 Tue Dec 10 04:43:23 2019 +0000
+++ b/libpurple/plugins.c Mon Oct 21 16:31:36 2019 +0200
@@ -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 Tue Dec 10 04:43:23 2019 +0000
+++ b/libpurple/plugins/purple-toast.c Mon Oct 21 16:31:36 2019 +0200
@@ -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 Tue Dec 10 04:43:23 2019 +0000
+++ b/libpurple/protocols/jabber/caps.c Mon Oct 21 16:31:36 2019 +0200
@@ -902,6 +902,7 @@
ret = g_base64_encode(checksum, checksum_size);
g_free(checksum);
+ g_checksum_free(hash);
return ret;
}
--- a/libpurple/protocols/jabber/jabber.c Tue Dec 10 04:43:23 2019 +0000
+++ b/libpurple/protocols/jabber/jabber.c Mon Oct 21 16:31:36 2019 +0200
@@ -1686,6 +1686,12 @@
g_free(js->google_relay_token);
g_free(js->google_relay_host);
+ if (js->sessions) {
+ g_hash_table_remove_all(js->sessions);
+ g_hash_table_unref(js->sessions);
+ js->sessions = NULL;
+ }
+
g_free(js);
purple_connection_set_protocol_data(gc, NULL);
--- a/libpurple/protocols/jabber/jingle/iceudp.c Tue Dec 10 04:43:23 2019 +0000
+++ b/libpurple/protocols/jabber/jingle/iceudp.c Mon Oct 21 16:31:36 2019 +0200
@@ -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/rtp.c Tue Dec 10 04:43:23 2019 +0000
+++ b/libpurple/protocols/jabber/jingle/rtp.c Mon Oct 21 16:31:36 2019 +0200
@@ -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/pidgin/gtkblist.c Tue Dec 10 04:43:23 2019 +0000
+++ b/pidgin/gtkblist.c Mon Oct 21 16:31:36 2019 +0200
@@ -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 Tue Dec 10 04:43:23 2019 +0000
+++ b/pidgin/gtkmedia.c Mon Oct 21 16:31:36 2019 +0200
@@ -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 Tue Dec 10 04:43:23 2019 +0000
+++ b/pidgin/gtkrequest.c Mon Oct 21 16:31:36 2019 +0200
@@ -2485,13 +2485,13 @@
static void
pidgin_window_detach_children(GtkWindow* win)
{
- GList *it;
+ GList *it, *l;
GtkWindow *par;
g_return_if_fail(win != NULL);
par = gtk_window_get_transient_for(win);
- it = gtk_window_list_toplevels();
+ l = it = gtk_window_list_toplevels();
for (it = g_list_first(it); it != NULL; it = g_list_next(it)) {
GtkWindow *child = GTK_WINDOW(it->data);
if (gtk_window_get_transient_for(child) != win)
@@ -2506,6 +2506,7 @@
}
gtk_window_set_transient_for(child, par);
}
+ g_list_free(l);
}
static void
--- a/pidgin/gtkstatusbox.c Tue Dec 10 04:43:23 2019 +0000
+++ b/pidgin/gtkstatusbox.c Mon Oct 21 16:31:36 2019 +0200
@@ -496,6 +496,7 @@
PidginStatusBox *statusbox = PIDGIN_STATUS_BOX(obj);
destroy_icon_box(statusbox);
+ G_OBJECT_CLASS(parent_class)->dispose(obj);
}
static void