[evolution-data-server] Fix two memory leaks
- From: Milan Crha <mcrha src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [evolution-data-server] Fix two memory leaks
- Date: Fri, 16 Aug 2019 10:59:28 +0000 (UTC)
commit 412947c35373a31102147f195057bbe1e2267633
Author: Milan Crha <mcrha redhat com>
Date: Fri Aug 16 12:59:06 2019 +0200
Fix two memory leaks
src/libedataserver/e-oauth2-service.c | 14 +++++++++++---
src/modules/secret-monitor/module-secret-monitor.c | 10 ++++++++--
2 files changed, 19 insertions(+), 5 deletions(-)
---
diff --git a/src/libedataserver/e-oauth2-service.c b/src/libedataserver/e-oauth2-service.c
index da6030a88..c4d295baf 100644
--- a/src/libedataserver/e-oauth2-service.c
+++ b/src/libedataserver/e-oauth2-service.c
@@ -1241,10 +1241,17 @@ eos_lookup_token_sync (EOAuth2Service *service,
*out_expires_in = num_expires_after - num_now - 1;
}
+ success = success && *out_refresh_token != NULL;
+
+ if (!success) {
+ g_clear_pointer (out_refresh_token, e_util_safe_free_string);
+ g_clear_pointer (out_access_token, e_util_safe_free_string);
+ }
+
e_util_safe_free_string (secret);
g_free (expires_after);
- return success && *out_refresh_token != NULL;
+ return success;
}
/**
@@ -1521,6 +1528,7 @@ e_oauth2_service_get_access_token_sync (EOAuth2Service *service,
ref_source, ref_source_user_data, cancellable, error);
g_clear_pointer (&refresh_token, e_util_safe_free_string);
+ g_clear_pointer (out_access_token, e_util_safe_free_string);
success = success && eos_lookup_token_sync (service, source, &refresh_token,
out_access_token, out_expires_in, cancellable, error);
}
@@ -1528,8 +1536,8 @@ e_oauth2_service_get_access_token_sync (EOAuth2Service *service,
e_util_safe_free_string (refresh_token);
if (success && *out_expires_in <= 0) {
- e_util_safe_free_string (*out_access_token);
- *out_access_token = NULL;
+ g_clear_pointer (out_access_token, e_util_safe_free_string);
+
success = FALSE;
g_set_error_literal (error, G_IO_ERROR, G_IO_ERROR_CONNECTION_REFUSED,
diff --git a/src/modules/secret-monitor/module-secret-monitor.c
b/src/modules/secret-monitor/module-secret-monitor.c
index 287a6290a..7c7e48713 100644
--- a/src/modules/secret-monitor/module-secret-monitor.c
+++ b/src/modules/secret-monitor/module-secret-monitor.c
@@ -135,12 +135,16 @@ secret_monitor_scan_secrets_thread (gpointer user_data)
uid = g_hash_table_lookup (attributes, KEYRING_ITEM_ATTRIBUTE_UID);
/* No UID attribute? Best leave it alone. */
- if (uid == NULL)
+ if (uid == NULL) {
+ g_hash_table_unref (attributes);
continue;
+ }
/* These are special keys, not referencing any real ESource */
- if (g_str_has_prefix (uid, "OAuth2::"))
+ if (g_str_has_prefix (uid, "OAuth2::")) {
+ g_hash_table_unref (attributes);
continue;
+ }
source = e_source_registry_server_ref_source (server, uid);
@@ -166,6 +170,8 @@ secret_monitor_scan_secrets_thread (gpointer user_data)
secret_item_delete_sync (item, NULL, &local_error);
}
+ g_hash_table_unref (attributes);
+
if (local_error != NULL)
break;
}
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]