Fix double unref issue. 36/178636/1
authorDeokhyun Kim <dukan.kim@samsung.com>
Fri, 11 May 2018 04:36:51 +0000 (13:36 +0900)
committerDeokhyun Kim <dukan.kim@samsung.com>
Fri, 11 May 2018 04:36:51 +0000 (13:36 +0900)
 - result is freed twice by g_variant_unref()

Change-Id: I9f3c344e4ff9f80c46dbef6415c41d855f784f70
Signed-off-by: Deokhyun Kim <dukan.kim@samsung.com>
bt-service/bt-service-device.c

index 35a8428..56a7ac7 100644 (file)
@@ -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,