Fix the prevent issue
[platform/core/connectivity/bluetooth-frwk.git] / bt-api / bt-common.c
index 4c7462b..75ae33c 100644 (file)
@@ -1922,12 +1922,17 @@ GVariant *_bt_get_managed_objects(void)
                        BT_MANAGER_INTERFACE,
                        NULL, &error);
 
-       if (manager_proxy == NULL && error) {
+       if (error) {
                BT_ERR("Unable to create proxy: %s", error->message);
                g_clear_error(&error);
+               if (manager_proxy)
+                       g_object_unref(manager_proxy);
                return NULL;
        }
 
+       if (!manager_proxy)
+               return NULL;
+
        result = g_dbus_proxy_call_sync(manager_proxy,
                        "GetManagedObjects", NULL,
                        G_DBUS_CALL_FLAGS_NONE, -1,