From: Segwon Date: Mon, 13 Feb 2017 10:44:58 +0000 (+0900) Subject: d2d-conv-setting : fix svace issue X-Git-Tag: accepted/tizen/3.0/mobile/20170215.033644^0 X-Git-Url: http://review.tizen.org/git/?a=commitdiff_plain;h=94c1a9b6daf07d510f614ea7adda65abfe9fe69b;p=profile%2Fmobile%2Fapps%2Fnative%2Fd2d-conv-setting.git 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: I9872ab9ae254727ded020d0ce84a0f2d2e8c485a --- 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 :