pidgin/pidgin

silc: Move more things to silcpurple_free.

2019-11-03, Elliott Sales de Andrade
29830983ace7
Parents 68872ce295a4
Children bc6bb63ae605
silc: Move more things to silcpurple_free.
--- a/libpurple/protocols/silc/silc.c Sun Nov 03 17:16:20 2019 -0500
+++ b/libpurple/protocols/silc/silc.c Sun Nov 03 20:20:13 2019 -0500
@@ -45,9 +45,19 @@
static void
silcpurple_free(SilcPurple sg)
{
+ g_return_if_fail(sg != NULL);
+
g_cancellable_cancel(sg->cancellable);
g_clear_object(&sg->cancellable);
g_clear_object(&sg->sockconn);
+
+ g_clear_pointer(&sg->client, silc_client_free);
+ g_clear_pointer(&sg->sha1hash, silc_hash_free);
+ g_clear_pointer(&sg->mimeass, silc_mime_assembler_free);
+
+ g_clear_pointer(&sg->public_key, silc_pkcs_public_key_free);
+ g_clear_pointer(&sg->private_key, silc_pkcs_private_key_free);
+
silc_free(sg);
}
@@ -377,8 +387,6 @@
purple_connection_error(gc,
PURPLE_CONNECTION_ERROR_NETWORK_ERROR,
_("Connection failed"));
- silc_pkcs_public_key_free(sg->public_key);
- silc_pkcs_private_key_free(sg->private_key);
silcpurple_free(sg);
purple_connection_set_protocol_data(gc, NULL);
return;
@@ -431,8 +439,6 @@
if (!g_error_matches(error, G_IO_ERROR, G_IO_ERROR_CANCELLED)) {
purple_connection_error(gc, PURPLE_CONNECTION_ERROR_NETWORK_ERROR,
_("Connection failed"));
- silc_pkcs_public_key_free(sg->public_key);
- silc_pkcs_private_key_free(sg->private_key);
silcpurple_free(sg);
purple_connection_set_protocol_data(gc, NULL);
}
@@ -682,11 +688,7 @@
purple_debug_info("silc", "Finalizing SilcPurple %p\n", sg);
silc_client_stop(sg->client, NULL, NULL);
- silc_client_free(sg->client);
- if (sg->sha1hash)
- silc_hash_free(sg->sha1hash);
- if (sg->mimeass)
- silc_mime_assembler_free(sg->mimeass);
+
silcpurple_free(sg);
return 0;
}