diff options
author | Segwon <segwon.han@samsung.com> | 2017-02-13 18:33:31 +0900 |
---|---|---|
committer | Segwon <segwon.han@samsung.com> | 2017-02-13 19:24:29 +0900 |
commit | 5a605ed39bc77a77108e83af539b096c7d207c0e (patch) | |
tree | d046cab9a1ad2afd3379681523c7239475a15bf6 | |
parent | f81336512cd66edce9fea00c024105e6198821f1 (diff) | |
download | d2d-conv-setting-5a605ed39bc77a77108e83af539b096c7d207c0e.tar.gz d2d-conv-setting-5a605ed39bc77a77108e83af539b096c7d207c0e.tar.bz2 d2d-conv-setting-5a605ed39bc77a77108e83af539b096c7d207c0e.zip |
d2d-conv-setting : fix svace issuesubmit/tizen/20170214.004622accepted/tizen/mobile/20170214.225709
Pointer variable obtained from conv_device_get_property_string() was allocated.
Added free function to prevent memory leak.
Signed-off-by: Segwon <segwon.han@samsung.com>
Change-Id: I18f46bff6a5be3291ba5a680b5ccbb96487300d0
-rw-r--r-- | src/ui/setting_item_device_list.c | 22 |
1 files 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 : |