From dedd78089fb6b5238546a45284624181ea38c306 Mon Sep 17 00:00:00 2001 From: DoHyun Pyun Date: Mon, 23 Mar 2020 09:15:22 +0900 Subject: [PATCH] Fix the coverity issue (Resource leak) Change-Id: I94e04b563a9fa7af11e0c6c49ff115f987d9270e Signed-off-by: DoHyun Pyun --- bt-oal/bluez_hal/src/bt-hal-gatt-client.c | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/bt-oal/bluez_hal/src/bt-hal-gatt-client.c b/bt-oal/bluez_hal/src/bt-hal-gatt-client.c index f0c82ec..4a0a9e6 100644 --- a/bt-oal/bluez_hal/src/bt-hal-gatt-client.c +++ b/bt-oal/bluez_hal/src/bt-hal-gatt-client.c @@ -3886,7 +3886,9 @@ static bt_status_t __hal_gattc_get_service_info(hal_gattc_server_info_t *server_ } else if (g_strcmp0(key, "Characteristics") == 0) { g_variant_get(value, "ao", &char_iter); if (char_iter != NULL) { - gp_char_array = g_ptr_array_new(); + if (gp_char_array == NULL) + gp_char_array = g_ptr_array_new(); + while (g_variant_iter_loop(char_iter, "&o", &char_handle)) { DBG("char_handle: %s", char_handle); g_ptr_array_add(gp_char_array, (gpointer)char_handle); -- 2.7.4