parent
5836e40ca2
commit
ce82be3b6d
@ -1,60 +0,0 @@
|
||||
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
|
||||
|
@ -1,34 +0,0 @@
|
||||
From 207139e65e6707100d2e92d96b1a4c3bfaa88a5f Mon Sep 17 00:00:00 2001
|
||||
From: Mikko Harju <mikko.harju@jolla.com>
|
||||
Date: Thu, 13 Aug 2015 03:09:07 -0400
|
||||
Subject: [PATCH 5/6] Use gboolean instead of bool
|
||||
|
||||
The "use-dbus" is a boolean g_object property, with actual type of
|
||||
gboolean, and gboolean is typedef int. g_object_get is a variadic
|
||||
function (no static type checking), and stores the queried value
|
||||
through pointer-to-int. If sizeof(bool) happens to be less than
|
||||
sizeof(int) and the stack variable useDBus is packed tightly,
|
||||
this can lead to stack corruption.
|
||||
|
||||
Compiling the lib with -fstack-protector immediately pointed out
|
||||
the problem.
|
||||
---
|
||||
Accounts/manager.cpp | 2 +-
|
||||
1 file changed, 1 insertion(+), 1 deletion(-)
|
||||
|
||||
diff --git a/Accounts/manager.cpp b/Accounts/manager.cpp
|
||||
index 2eb077f..1ac78d0 100644
|
||||
--- a/Accounts/manager.cpp
|
||||
+++ b/Accounts/manager.cpp
|
||||
@@ -530,7 +530,7 @@ bool Manager::abortOnTimeout() const
|
||||
*/
|
||||
Manager::Options Manager::options() const
|
||||
{
|
||||
- bool useDBus = true;
|
||||
+ gboolean useDBus = true;
|
||||
g_object_get(d->m_manager,
|
||||
"use-dbus", &useDBus,
|
||||
NULL);
|
||||
--
|
||||
2.5.0
|
||||
|
Loading…
Reference in new issue