/cpw/tomkiewicz/masterpassword: 34c3dbf12e95: Fix some memleaks
Tomasz Wasilczyk
tomkiewicz at cpw.pidgin.im
Thu Mar 21 16:50:36 EDT 2013
Changeset: 34c3dbf12e955349c04762d3c07883798f423a3d
Author: Tomasz Wasilczyk <tomkiewicz at cpw.pidgin.im>
Date: 2013-03-21 21:50 +0100
Branch: soc.2008.masterpassword
URL: https://hg.pidgin.im/cpw/tomkiewicz/masterpassword/rev/34c3dbf12e95
Description:
Fix some memleaks
diffstat:
libpurple/account.c | 3 +--
libpurple/core.c | 2 +-
libpurple/keyring.c | 32 +++++++++++++++++++++++++-------
libpurple/plugins/keyrings/kwallet.cpp | 1 +
4 files changed, 28 insertions(+), 10 deletions(-)
diffs (120 lines):
diff --git a/libpurple/account.c b/libpurple/account.c
--- a/libpurple/account.c
+++ b/libpurple/account.c
@@ -879,7 +879,6 @@ parse_account(xmlnode *node)
const char *mode = NULL;
char *data = NULL;
gboolean result = FALSE;
- GError *error = NULL;
child = xmlnode_get_child(node, "protocol");
if (child != NULL)
@@ -978,7 +977,7 @@ parse_account(xmlnode *node)
mode = xmlnode_get_attrib(child, "mode");
data = xmlnode_get_data(child);
- result = purple_keyring_import_password(ret, keyring_id, mode, data, &error);
+ result = purple_keyring_import_password(ret, keyring_id, mode, data, NULL);
if (result == TRUE) {
purple_debug_info("account", "Password imported successfully.\n");
diff --git a/libpurple/core.c b/libpurple/core.c
--- a/libpurple/core.c
+++ b/libpurple/core.c
@@ -222,7 +222,7 @@ purple_core_quit(void)
*/
purple_certificate_uninit();
- /* The SSL plugins must be uninit before they're unloaded */
+ /* The SSL and keyring plugins must be uninit before they're unloaded */
purple_ssl_uninit();
purple_keyring_uninit();
diff --git a/libpurple/keyring.c b/libpurple/keyring.c
--- a/libpurple/keyring.c
+++ b/libpurple/keyring.c
@@ -86,6 +86,8 @@ purple_keyring_new(void)
void
purple_keyring_free(PurpleKeyring *keyring)
{
+ g_free(keyring->name);
+ g_free(keyring->id);
g_free(keyring);
}
@@ -331,6 +333,7 @@ void
purple_keyring_uninit(void)
{
GList *it;
+ PurpleCore *core = purple_get_core();
g_free(purple_keyring_to_use);
purple_keyring_inuse = NULL;
@@ -345,6 +348,11 @@ purple_keyring_uninit(void)
}
g_list_free(purple_keyring_loaded_plugins);
purple_keyring_loaded_plugins = NULL;
+
+ purple_signal_unregister(core, "keyring-register");
+ purple_signal_unregister(core, "keyring-unregister");
+ purple_prefs_disconnect_callback(purple_keyring_pref_cb_id);
+ purple_keyring_pref_cb_id = 0;
}
PurpleKeyring *
@@ -752,8 +760,12 @@ purple_keyring_import_password(PurpleAcc
inuse = purple_keyring_get_inuse();
if (inuse == NULL) {
- *error = g_error_new(PURPLE_KEYRING_ERROR, PURPLE_KEYRING_ERROR_NOKEYRING,
- "No keyring configured, cannot import password info");
+ if (error != NULL) {
+ *error = g_error_new(PURPLE_KEYRING_ERROR,
+ PURPLE_KEYRING_ERROR_NOKEYRING,
+ "No keyring configured, cannot import password "
+ "info");
+ }
purple_debug_info("Keyring",
"No keyring configured, cannot import password info for account %s (%s).\n",
purple_account_get_username(account), purple_account_get_protocol_id(account));
@@ -768,9 +780,12 @@ purple_keyring_import_password(PurpleAcc
*/
if ((keyringid != NULL && g_strcmp0(realid, keyringid) != 0) ||
(keyringid == NULL && g_strcmp0(PURPLE_DEFAULT_KEYRING, realid))) {
-
- *error = g_error_new(PURPLE_KEYRING_ERROR, PURPLE_KEYRING_ERROR_INVALID,
- "Specified keyring id does not match the configured one.");
+ if (error != NULL) {
+ *error = g_error_new(PURPLE_KEYRING_ERROR,
+ PURPLE_KEYRING_ERROR_INVALID,
+ "Specified keyring id does not match the "
+ "configured one.");
+ }
purple_debug_info("keyring",
"Specified keyring id does not match the configured one (%s vs. %s). Data will be lost.\n",
keyringid, realid);
@@ -779,8 +794,11 @@ purple_keyring_import_password(PurpleAcc
import = purple_keyring_get_import_password(inuse);
if (import == NULL) {
- *error = g_error_new(PURPLE_KEYRING_ERROR, PURPLE_KEYRING_ERROR_NOCAP,
- "Keyring cannot import password info.");
+ if (error != NULL) {
+ *error = g_error_new(PURPLE_KEYRING_ERROR,
+ PURPLE_KEYRING_ERROR_NOCAP,
+ "Keyring cannot import password info.");
+ }
purple_debug_info("Keyring", "Configured keyring cannot import password info. This might be normal.\n");
return FALSE;
}
diff --git a/libpurple/plugins/keyrings/kwallet.cpp b/libpurple/plugins/keyrings/kwallet.cpp
--- a/libpurple/plugins/keyrings/kwallet.cpp
+++ b/libpurple/plugins/keyrings/kwallet.cpp
@@ -490,6 +490,7 @@ kwallet_unload(PurplePlugin *plugin)
kwallet_close(NULL);
+ purple_keyring_unregister(keyring_handler);
purple_keyring_free(keyring_handler);
keyring_handler = NULL;
More information about the Commits
mailing list