From 22fec6beb3bd5fc93da9d0245583f3b7034bd111 Mon Sep 17 00:00:00 2001 From: Deokhyun Kim Date: Fri, 11 May 2018 13:36:51 +0900 Subject: [PATCH] Fix double unref issue. - result is freed twice by g_variant_unref() Change-Id: I9f3c344e4ff9f80c46dbef6415c41d855f784f70 Signed-off-by: Deokhyun Kim --- bt-service/bt-service-device.c | 13 +++++-------- 1 file changed, 5 insertions(+), 8 deletions(-) diff --git a/bt-service/bt-service-device.c b/bt-service/bt-service-device.c index 35a8428..56a7ac7 100644 --- a/bt-service/bt-service-device.c +++ b/bt-service/bt-service-device.c @@ -1504,7 +1504,6 @@ int _bt_set_authorization(bluetooth_device_address_t *device_address, GDBusConnection *conn; GVariant *result = NULL; GVariant *temp = NULL; - int ret = BLUETOOTH_ERROR_NONE; BT_CHECK_PARAMETER(device_address, return); @@ -1548,8 +1547,7 @@ int _bt_set_authorization(bluetooth_device_address_t *device_address, if (previous_value == authorize) { BT_ERR("Same value: %d", previous_value); g_object_unref(device_proxy); - ret = BLUETOOTH_ERROR_INVALID_PARAM; - goto done; + return BLUETOOTH_ERROR_INVALID_PARAM; } result = g_dbus_proxy_call_sync(device_proxy, "Set", @@ -1563,13 +1561,12 @@ int _bt_set_authorization(bluetooth_device_address_t *device_address, if (error) { BT_ERR("SetProperty error: [%s]", error->message); g_error_free(error); - ret = BLUETOOTH_ERROR_INTERNAL; + return BLUETOOTH_ERROR_INTERNAL; } -done: - if (result) - g_variant_unref(result); - return ret; + g_variant_unref(result); + + return BLUETOOTH_ERROR_NONE; } int _bt_is_gatt_connected(bluetooth_device_address_t *device_address, -- 2.7.4