diff options
author | Segwon <segwon.han@samsung.com> | 2017-07-18 12:06:44 +0900 |
---|---|---|
committer | Segwon <segwon.han@samsung.com> | 2017-07-21 14:30:03 +0900 |
commit | cca6edad631e5a65ce786344238cc17fc110c373 (patch) | |
tree | 93b015c38eaf4a576d5700849cdc27c16b610206 /src | |
parent | 003fe4d3f445e4450d28f7f0ced619b463ba167e (diff) | |
download | d2d-conv-setting-accepted/tizen_3.0_wearable.tar.gz d2d-conv-setting-accepted/tizen_3.0_wearable.tar.bz2 d2d-conv-setting-accepted/tizen_3.0_wearable.zip |
Modified to free the device info.submit/tizen_3.0/20170721.060334accepted/tizen/3.0/wearable/20170724.032202tizen_3.0accepted/tizen_3.0_wearable
(+ Major SVACE Issue : Check if dynamically allocated pointer is not NULL)
Signed-off-by: Segwon <segwon.han@samsung.com>
Change-Id: I884c1f8f3a05d1b6ca4acfe3a77c0ff0010feb33
Diffstat (limited to 'src')
-rw-r--r-- | src/main.c | 4 | ||||
-rw-r--r-- | src/ui/setting_item_allowed_device_list.c | 20 | ||||
-rw-r--r-- | src/ui/setting_item_denied_device_list.c | 19 | ||||
-rw-r--r-- | src/ui/setting_item_discovery.c | 43 |
4 files changed, 58 insertions, 28 deletions
@@ -16,6 +16,8 @@ #include "main.h" +appdata_s *ad = NULL; + static void win_delete_request_cb(void *data, Evas_Object *obj, void *event_info) { ui_app_exit(); @@ -91,7 +93,7 @@ static void app_terminate(void *data) static void init_appdata() { ad = (appdata_s*)malloc(sizeof(appdata_s)); - { + if (ad != NULL) { ad->win = NULL; ad->conform = NULL; ad->circle_surface = NULL; diff --git a/src/ui/setting_item_allowed_device_list.c b/src/ui/setting_item_allowed_device_list.c index 262a521..3c190d6 100644 --- a/src/ui/setting_item_allowed_device_list.c +++ b/src/ui/setting_item_allowed_device_list.c @@ -93,6 +93,10 @@ static void show_acl_menu(void *data, Evas_Object *obj, void *event_info) device_info_s *info = (device_info_s *)data; selected_device = (device_info_s *) calloc(sizeof(device_info_s), 1); + if (selected_device == NULL) { + return; + } + selected_device->index = info->index; selected_device->name = info->name; selected_device->type = info->type; @@ -134,13 +138,16 @@ static void show_acl_menu(void *data, Evas_Object *obj, void *event_info) static void get_acl_list_foreach_cb(char *mac_address, char *device_type, char *device_name, int access_control_state, void *user_data) { if(access_control_state == 0) { - int index = ++devices_index; + int index = devices_index + 1; devices_info[index] = (device_info_s *) calloc(sizeof(device_info_s), 1); - devices_info[index]->index = index; - devices_info[index]->name = strdup(device_name); - devices_info[index]->type = strdup(device_type); - devices_info[index]->mac_address = strdup(mac_address); - elm_genlist_item_insert_after(genlist, device_list_item_builder, devices_info[index], NULL, title_item, ELM_GENLIST_ITEM_NONE, show_acl_menu, devices_info[index]); + if (devices_info[index] != NULL) { + devices_info[index]->index = index; + devices_info[index]->name = strdup(device_name); + devices_info[index]->type = strdup(device_type); + devices_info[index]->mac_address = strdup(mac_address); + devices_index++; + elm_genlist_item_insert_after(genlist, device_list_item_builder, devices_info[index], NULL, title_item, ELM_GENLIST_ITEM_NONE, show_acl_menu, devices_info[index]); + } } } @@ -148,7 +155,6 @@ static void set_acl_device_list() { device_info_free(); devices_info = (device_info_s **) calloc(STORAGE_SIZE, sizeof(device_info_s *)); - conv_internal_get_acl_list(get_acl_list_foreach_cb, NULL); } diff --git a/src/ui/setting_item_denied_device_list.c b/src/ui/setting_item_denied_device_list.c index d317985..8a5aaec 100644 --- a/src/ui/setting_item_denied_device_list.c +++ b/src/ui/setting_item_denied_device_list.c @@ -93,6 +93,9 @@ static void show_acl_menu(void *data, Evas_Object *obj, void *event_info) device_info_s *info = (device_info_s *)data; selected_device = (device_info_s *) calloc(sizeof(device_info_s), 1); + if (selected_device == NULL) { + return; + } selected_device->index = info->index; selected_device->name = info->name; selected_device->type = info->type; @@ -134,13 +137,16 @@ static void show_acl_menu(void *data, Evas_Object *obj, void *event_info) static void get_acl_list_foreach_cb(char *mac_address, char *device_type, char *device_name, int access_control_state, void *user_data) { if(access_control_state == 1) { - int index = ++devices_index; + int index = devices_index + 1; devices_info[index] = (device_info_s *) calloc(sizeof(device_info_s), 1); - devices_info[index]->index = index; - devices_info[index]->name = strdup(device_name); - devices_info[index]->type = strdup(device_type); - devices_info[index]->mac_address = strdup(mac_address); - elm_genlist_item_insert_after(genlist, device_list_item_builder, devices_info[index], NULL, title_item, ELM_GENLIST_ITEM_NONE, show_acl_menu, devices_info[index]); + if (devices_info[index] != NULL) { + devices_info[index]->index = index; + devices_info[index]->name = strdup(device_name); + devices_info[index]->type = strdup(device_type); + devices_info[index]->mac_address = strdup(mac_address); + devices_index++; + elm_genlist_item_insert_after(genlist, device_list_item_builder, devices_info[index], NULL, title_item, ELM_GENLIST_ITEM_NONE, show_acl_menu, devices_info[index]); + } } } @@ -148,7 +154,6 @@ static void set_acl_device_list() { device_info_free(); devices_info = (device_info_s **) calloc(STORAGE_SIZE, sizeof(device_info_s *)); - conv_internal_get_acl_list(get_acl_list_foreach_cb, NULL); } diff --git a/src/ui/setting_item_discovery.c b/src/ui/setting_item_discovery.c index 24c7946..fefcb44 100644 --- a/src/ui/setting_item_discovery.c +++ b/src/ui/setting_item_discovery.c @@ -102,6 +102,9 @@ static void show_acl_menu(void *data, Evas_Object *obj, void *event_info) device_info_s *info = (device_info_s *)data; selected_device = (device_info_s *) calloc(sizeof(device_info_s), 1); + if (selected_device == NULL) { + return; + } selected_device->index = info->index; selected_device->name = info->name; selected_device->type = info->type; @@ -140,11 +143,17 @@ static void show_acl_menu(void *data, Evas_Object *obj, void *event_info) elm_naviframe_item_pop_cb_set(it, setting_menu_pop_cb, NAVI_FRAME_CHILD); } +static void device_properties_free(char **data) +{ + free(*data); + *data = NULL; +} + static void discovery_foreach_cb(conv_device_h device_h, int result, void *data) { - char *device_id = NULL; - char *device_name = NULL; - char *device_type = NULL; + char *device_id __attribute__ ((__cleanup__(device_properties_free))) = NULL; + char *device_name __attribute__ ((__cleanup__(device_properties_free))) = NULL; + char *device_type __attribute__ ((__cleanup__(device_properties_free))) = NULL; switch (result) { @@ -156,15 +165,21 @@ static void discovery_foreach_cb(conv_device_h device_h, int result, void *data) case CONV_DISCOVERY_RESULT_SUCCESS : + dlog_print(DLOG_INFO, LOG_TAG, "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) { + return; + } + 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 <= devices_index; index++) { if (!strcmp(devices_info[index]->mac_address, device_id)) { @@ -172,14 +187,16 @@ static void discovery_foreach_cb(conv_device_h device_h, int result, void *data) } } - index = ++devices_index; + index = devices_index + 1; devices_info[index] = (device_info_s *) calloc(sizeof(device_info_s), 1); - devices_info[index]->index = index; - devices_info[index]->name = device_name; - devices_info[index]->type = device_type; - devices_info[index]->mac_address = device_id; - - elm_genlist_item_insert_after(genlist, device_list_item_builder, devices_info[index], NULL, title_item, ELM_GENLIST_ITEM_NONE, show_acl_menu, devices_info[index]); + if (devices_info[index] != NULL) { + devices_info[index]->index = index; + devices_info[index]->name = strdup(device_name); + devices_info[index]->type = strdup(device_type); + devices_info[index]->mac_address = strdup(device_id); + devices_index++; + elm_genlist_item_insert_after(genlist, device_list_item_builder, devices_info[index], NULL, title_item, ELM_GENLIST_ITEM_NONE, show_acl_menu, devices_info[index]); + } return; |