From: Amit Purwar Date: Fri, 21 Jul 2017 10:49:15 +0000 (+0530) Subject: added the failure condition for realloc X-Git-Tag: submit/tizen/20170724.081454~1 X-Git-Url: http://review.tizen.org/git/?a=commitdiff_plain;h=refs%2Fchanges%2F20%2F140020%2F2;p=platform%2Fcore%2Fconnectivity%2Fbluetooth-frwk.git added the failure condition for realloc removed the print after return Change-Id: I1dfb2bf75f36c9c1b71651c480c5eaa1a7a01d04 Signed-off-by: Amit Purwar --- 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,