added the failure condition for realloc 20/140020/2
authorAmit Purwar <amit.purwar@samsung.com>
Fri, 21 Jul 2017 10:49:15 +0000 (16:19 +0530)
committerAmit Purwar <amit.purwar@samsung.com>
Mon, 24 Jul 2017 04:53:53 +0000 (10:23 +0530)
removed the print after return

Change-Id: I1dfb2bf75f36c9c1b71651c480c5eaa1a7a01d04
Signed-off-by: Amit Purwar <amit.purwar@samsung.com>
bt-api/bt-gatt-service.c
bt-api/bt-hdp.c

index 77bee58..dee2963 100644 (file)
@@ -2369,6 +2369,7 @@ BT_EXPORT_API int bluetooth_gatt_update_characteristic(
        int i = 0;
        gchar **line_argv = NULL;
        gchar *serv_path = NULL;
+       const char *value = NULL;
 
        line_argv = g_strsplit_set(char_path, "/", 0);
        serv_path = g_strdup_printf("/%s/%s/%s", line_argv[1], line_argv[2], line_argv[3]);
@@ -2427,7 +2428,18 @@ BT_EXPORT_API int bluetooth_gatt_update_characteristic(
 
                char_info->value_length = value_length;
 
-               char_info->char_value = (char *)realloc(char_info->char_value, value_length);
+               value = (char *)realloc(char_info->char_value, value_length);
+               if (value == NULL) {
+                       g_free(serv_path);
+                       g_strfreev(line_argv);
+                       g_variant_builder_unref(inner_builder);
+                       g_variant_builder_unref(outer_builder);
+                       g_variant_builder_unref(invalidated_builder);
+
+                       return BLUETOOTH_ERROR_MEMORY_ALLOCATION;
+               }
+
+               char_info->char_value = (char*)value;
                if (char_info->char_value) {
                        for (i = 0; i < value_length; i++)
                                char_info->char_value[i] = char_value[i];
index aae774b..5a5675c 100755 (executable)
@@ -291,8 +291,6 @@ static int __bt_hdp_internal_add_filter(void)
 
 
        return __bt_hdp_add_filter_subscribe_signal(g_hdp_dus_conn, TRUE);
-
-       BT_DBG("-\n");
 }
 
 static void __bt_hdp_internal_event_filter(GDBusConnection *connection,