You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
libaccounts-qt/0002-Fix-memory-leaks-found...

61 lines
1.9 KiB

From 533aa917f2de9030a05e745a0e49a53a7fb4b36e Mon Sep 17 00:00:00 2001
From: Vyacheslav Monich <vyacheslav.monich@gmail.com>
Date: Fri, 5 Sep 2014 16:23:44 +0300
Subject: [PATCH 2/6] Fix memory leaks found by valgrind
Fixes: https://code.google.com/p/accounts-sso/issues/detail?id=239
---
Accounts/account-service.cpp | 4 +++-
Accounts/auth-data.cpp | 1 +
Accounts/utils.cpp | 4 +++-
3 files changed, 7 insertions(+), 2 deletions(-)
diff --git a/Accounts/account-service.cpp b/Accounts/account-service.cpp
index 9da8f8c..6661685 100644
--- a/Accounts/account-service.cpp
+++ b/Accounts/account-service.cpp
@@ -504,5 +504,7 @@ AuthData AccountService::authData() const
AgAuthData *agAuthData =
ag_account_service_get_auth_data(d->m_accountService);
- return AuthData(agAuthData);
+ AuthData authData(agAuthData);
+ ag_auth_data_unref(agAuthData);
+ return authData;
}
diff --git a/Accounts/auth-data.cpp b/Accounts/auth-data.cpp
index ef4b8d9..ed30396 100644
--- a/Accounts/auth-data.cpp
+++ b/Accounts/auth-data.cpp
@@ -109,6 +109,7 @@ QVariantMap AuthData::parameters() const
if (glibParameters == 0) return QVariantMap();
QVariant variant = gVariantToQVariant(glibParameters);
+ g_variant_unref(glibParameters);
if (!variant.isValid()) return QVariantMap();
return variant.toMap();
diff --git a/Accounts/utils.cpp b/Accounts/utils.cpp
index 71e24b6..dd0c7e1 100644
--- a/Accounts/utils.cpp
+++ b/Accounts/utils.cpp
@@ -32,12 +32,14 @@ static QVariantMap gVariantToQVariantMap(GVariant *variant)
{
QVariantMap ret;
GVariantIter iter;
- const gchar *key;
+ gchar *key;
GVariant *value;
g_variant_iter_init (&iter, variant);
while (g_variant_iter_next (&iter, "{sv}", &key, &value)) {
ret.insert(UTF8(key), gVariantToQVariant(value));
+ g_variant_unref(value);
+ g_free(key);
}
return ret;
--
2.5.0