Fix the memory leak
[platform/core/connectivity/bluetooth-frwk.git] / bt-service / bt-service-device.c
index 98da9f8..3a50a4e 100644 (file)
@@ -490,9 +490,8 @@ bt_remote_dev_info_t *_bt_get_remote_device_info_by_object_path(
                g_variant_get(tmp_value, "s", &address);
                g_variant_unref(tmp_value);
 
-               dev_info->address = g_strdup(address);
-               dev_info->name = g_strdup(name);
-               g_free(name);
+               dev_info->address = address;
+               dev_info->name = name;
                g_variant_unref(value);
        } else {
                BT_ERR("result  is NULL\n");
@@ -3118,21 +3117,16 @@ int _bt_get_device_ida(bluetooth_device_address_t *device_address,
        retv_if(device_path == NULL, BLUETOOTH_ERROR_NOT_PAIRED);
 
        device_proxy = g_dbus_proxy_new_sync(conn, G_DBUS_PROXY_FLAGS_NONE,
-                                                               NULL, BT_BLUEZ_NAME,
-                                                               device_path, BT_DEVICE_INTERFACE,  NULL, NULL);
+                       NULL, BT_BLUEZ_NAME,
+                       device_path, BT_DEVICE_INTERFACE,  NULL, NULL);
        g_free(device_path);
        if (!device_proxy) {
                BT_ERR("Unable to get proxy");
                return BLUETOOTH_ERROR_INTERNAL;
        }
 
-       result = g_dbus_proxy_call_sync(device_proxy, "GetIDAddress",
-                                NULL,
-                                G_DBUS_CALL_FLAGS_NONE,
-                                -1,
-                                NULL,
-                                &error);
-
+       result = g_dbus_proxy_call_sync(device_proxy, "GetIDAddress", NULL,
+                       G_DBUS_CALL_FLAGS_NONE, -1, NULL, &error);
        if (result == NULL) {
                BT_ERR("Failed to get device ID address");
                if (error != NULL) {
@@ -3143,22 +3137,16 @@ int _bt_get_device_ida(bluetooth_device_address_t *device_address,
                return BLUETOOTH_ERROR_INTERNAL;
        }
 
-       g_variant_get(result , "(s)", &idaddress);
-       g_variant_unref(result);
-
+       g_variant_get(result , "(&s)", &idaddress);
        if (idaddress == NULL) {
                BT_ERR("No paired device");
-               g_object_unref(device_proxy);
-               return BLUETOOTH_ERROR_NOT_PAIRED;
-       }
-
-       BT_DBG("ID Address:%s", idaddress);
-
-       if (idaddress)
+               ret = BLUETOOTH_ERROR_NOT_PAIRED;
+       } else {
+               DBG_SECURE("ID Address : %s", idaddress);
                _bt_convert_addr_string_to_type(id_address->addr, idaddress);
-       else
-               ret = BLUETOOTH_ERROR_INTERNAL;
+       }
 
+       g_variant_unref(result);
        g_object_unref(device_proxy);
 
        return ret;