GATT: Fix segmentation fault while using GATT RELAY feature 60/157460/2
authorAnupam Roy <anupam.r@samsung.com>
Tue, 24 Oct 2017 12:34:37 +0000 (18:04 +0530)
committerAnupam Roy <anupam.r@samsung.com>
Tue, 24 Oct 2017 12:42:27 +0000 (18:12 +0530)
bluetooth_gatt_set_descriptor_value() and bluetooth_gatt_register_service()
functions are to be used only in GATT DIRECT method.
These were wrongly placed inside GATT RELAY feature. Hence removed.
bluetooth_gatt_register_service() method was missed in GATT DIRECT method.

Change-Id: Ic8306e29069d34d429d57e5224fc5e88b1f8aba9
Signed-off-by: Anupam Roy <anupam.r@samsung.com>
src/bluetooth-gatt.c

index 4c74bed..b39ea42 100644 (file)
@@ -2662,24 +2662,9 @@ int bt_gatt_server_register_service(bt_gatt_server_h server, bt_gatt_h service)
                                goto fail;
                        }
 
-                       ret = _bt_get_error_code(bluetooth_gatt_set_descriptor_value(desc->path,
-                                       desc->value, desc->value_length));
-
-                       if (ret != BT_ERROR_NONE) {
-                               BT_ERR("%s(0x%08x)",
-                                       _bt_convert_error_to_string(ret), ret);
-                               goto fail;
-                       }
                }
        }
 
-       ret = _bt_get_error_code(bluetooth_gatt_register_service(svc->path));
-
-       if (ret != BT_ERROR_NONE) {
-               BT_ERR("%s(0x%08x)", _bt_convert_error_to_string(ret), ret);
-               goto fail;
-       }
-
        serv->services = g_slist_append(serv->services, svc);
        svc->parent = (void *)server;
 
@@ -2762,6 +2747,13 @@ int bt_gatt_server_register_service(bt_gatt_server_h server, bt_gatt_h service)
                }
        }
 
+       ret = _bt_get_error_code(bluetooth_gatt_register_service(svc->path));
+
+       if (ret != BT_ERROR_NONE) {
+               BT_ERR("%s(0x%08x)", _bt_convert_error_to_string(ret), ret);
+               goto fail;
+       }
+
        serv->services = g_slist_append(serv->services, svc);
        svc->parent = (void *)server;