summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorThomas Haller <thaller@redhat.com>2016-01-26 12:17:57 +0100
committerThomas Haller <thaller@redhat.com>2016-01-26 12:35:16 +0100
commit5ab7e899aac23e60bc7945d2eb54ec71f9243327 (patch)
treeea5778b9ce93f491cb39d4054af6b4256c51e541
parent1deae2a284fa42a14443b59a2d8915c5b8b21425 (diff)
downloadNetworkManager-5ab7e899aac23e60bc7945d2eb54ec71f9243327.tar.gz
libnm-glib: fix another memory leak around update_permissions()
This time in init_async_got_permissions(). Thereby, just use gs_unref_hash and gs_free_error for cleanup. (cherry picked from commit 8029f59e4fcefe9786fb79d04ede5ea10e3c33c2)
-rw-r--r--libnm-glib/nm-client.c19
1 files changed, 6 insertions, 13 deletions
diff --git a/libnm-glib/nm-client.c b/libnm-glib/nm-client.c
index bcbbaf74e3..280d5c71de 100644
--- a/libnm-glib/nm-client.c
+++ b/libnm-glib/nm-client.c
@@ -35,7 +35,7 @@
#include "nm-vpn-connection.h"
#include "nm-object-cache.h"
#include "nm-dbus-glib-types.h"
-#include "nm-glib-compat.h"
+#include "gsystem-local-alloc.h"
void _nm_device_wifi_set_wireless_enabled (NMDeviceWifi *device, gboolean enabled);
@@ -312,16 +312,13 @@ static gboolean
get_permissions_sync (NMClient *self, GError **error)
{
gboolean success;
- GHashTable *permissions = NULL;
+ gs_unref_hashtable GHashTable *permissions = NULL;
success = dbus_g_proxy_call_with_timeout (NM_CLIENT_GET_PRIVATE (self)->client_proxy,
"GetPermissions", 3000, error,
G_TYPE_INVALID,
DBUS_TYPE_G_MAP_OF_STRING, &permissions, G_TYPE_INVALID);
update_permissions (self, success ? permissions : NULL);
- if (permissions)
- g_hash_table_destroy (permissions);
-
return success;
}
@@ -331,17 +328,14 @@ get_permissions_reply (DBusGProxy *proxy,
gpointer user_data)
{
NMClient *self = NM_CLIENT (user_data);
- GHashTable *permissions = NULL;
- GError *error = NULL;
+ gs_unref_hashtable GHashTable *permissions = NULL;
+ gs_free_error GError *error = NULL;
dbus_g_proxy_end_call (proxy, call, &error,
DBUS_TYPE_G_MAP_OF_STRING, &permissions,
G_TYPE_INVALID);
NM_CLIENT_GET_PRIVATE (self)->perm_call = NULL;
update_permissions (NM_CLIENT (user_data), error ? NULL : permissions);
- if (permissions)
- g_hash_table_destroy (permissions);
- g_clear_error (&error);
}
static void
@@ -1875,14 +1869,13 @@ static void
init_async_got_permissions (DBusGProxy *proxy, DBusGProxyCall *call, gpointer user_data)
{
NMClientInitData *init_data = user_data;
- GHashTable *permissions;
- GError *error = NULL;
+ gs_unref_hashtable GHashTable *permissions = NULL;
+ gs_free_error GError *error = NULL;
dbus_g_proxy_end_call (proxy, call, &error,
DBUS_TYPE_G_MAP_OF_STRING, &permissions,
G_TYPE_INVALID);
update_permissions (init_data->client, error ? NULL : permissions);
- g_clear_error (&error);
init_data->permissions_pending = FALSE;
init_async_complete (init_data);