From 5a605ed39bc77a77108e83af539b096c7d207c0e Mon Sep 17 00:00:00 2001 From: Segwon Date: Mon, 13 Feb 2017 18:33:31 +0900 Subject: d2d-conv-setting : fix svace issue Pointer variable obtained from conv_device_get_property_string() was allocated. Added free function to prevent memory leak. Signed-off-by: Segwon Change-Id: I18f46bff6a5be3291ba5a680b5ccbb96487300d0 --- src/ui/setting_item_device_list.c | 22 ++++++++++++++++++---- 1 file changed, 18 insertions(+), 4 deletions(-) diff --git a/src/ui/setting_item_device_list.c b/src/ui/setting_item_device_list.c index 535f260..a125126 100644 --- a/src/ui/setting_item_device_list.c +++ b/src/ui/setting_item_device_list.c @@ -264,18 +264,22 @@ static void discovery_foreach_cb(conv_device_h device_h, int result, void *data) case CONV_DISCOVERY_RESULT_SUCCESS : conv_device_get_property_string(device_h, CONV_DEVICE_ID, &device_id); + conv_device_get_property_string(device_h, CONV_DEVICE_NAME, &device_name); + conv_device_get_property_string(device_h, CONV_DEVICE_TYPE, &device_type); + + if (device_id == NULL | device_name == NULL | device_type == NULL) { + goto MEMORY_FREE; + } + int device_id_index; for (device_id_index = 0; device_id_index < 5; device_id_index++) { device_id[2+(device_id_index*3)] = '-'; } - conv_device_get_property_string(device_h, CONV_DEVICE_NAME, &device_name); - conv_device_get_property_string(device_h, CONV_DEVICE_TYPE, &device_type); - int index; for (index = 0; index <= discovered_devices_index; index++) { if (!strcmp(discovered_devices_info[index]->mac_address, device_id)) { - return; + goto MEMORY_FREE; } } @@ -290,6 +294,16 @@ static void discovery_foreach_cb(conv_device_h device_h, int result, void *data) elm_genlist_item_append(discovered_list, device_item_builder, discovered_devices_info[index], discovered_device_group, ELM_GENLIST_ITEM_NONE, device_list_select_cb, discovered_devices_info[index]); elm_genlist_item_fields_update(discovered_device_group, "elm.swallow.end", ELM_GENLIST_ITEM_FIELD_CONTENT); +MEMORY_FREE: + if (device_id != NULL) { + free(device_id); + } + if (device_name != NULL) { + free(device_name); + } + if (device_type != NULL) { + free(device_type); + } return; case CONV_DISCOVERY_RESULT_FINISHED : -- cgit v1.2.3