From 41793e35381046adece99e7db5d820b19ed2c7fd Mon Sep 17 00:00:00 2001 From: Amit Purwar Date: Fri, 21 Jul 2017 16:19:15 +0530 Subject: [PATCH] added the failure condition for realloc removed the print after return Change-Id: I1dfb2bf75f36c9c1b71651c480c5eaa1a7a01d04 Signed-off-by: Amit Purwar --- bt-api/bt-gatt-service.c | 14 +++++++++++++- bt-api/bt-hdp.c | 2 -- 2 files changed, 13 insertions(+), 3 deletions(-) diff --git a/bt-api/bt-gatt-service.c b/bt-api/bt-gatt-service.c index 77bee58..dee2963 100644 --- a/bt-api/bt-gatt-service.c +++ b/bt-api/bt-gatt-service.c @@ -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]; diff --git a/bt-api/bt-hdp.c b/bt-api/bt-hdp.c index aae774b..5a5675c 100755 --- a/bt-api/bt-hdp.c +++ b/bt-api/bt-hdp.c @@ -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, -- 2.7.4