diff options
author | Segwon <segwon.han@samsung.com> | 2017-07-18 11:54:04 +0900 |
---|---|---|
committer | Segwon <segwon.han@samsung.com> | 2017-07-21 14:28:30 +0900 |
commit | b09858612989ef74ecee39f1fc85c8547ada24f1 (patch) | |
tree | 02dc4f6d86bf9908a7efa49e45535d7a9c237b9a | |
parent | 9a6b79ca3917ba41289047426fd6fb92d6b625b4 (diff) | |
download | d2d-conv-setting-accepted/tizen_unified.tar.gz d2d-conv-setting-accepted/tizen_unified.tar.bz2 d2d-conv-setting-accepted/tizen_unified.zip |
Modified to free the device info.submit/tizen_4.0_unified/20170814.115522submit/tizen_4.0/20170814.115522submit/tizen_4.0/20170811.094300submit/tizen/20170721.055326accepted/tizen/unified/20170721.202315accepted/tizen/4.0/unified/20170816.014422tizen_4.0tizenaccepted/tizen_unifiedaccepted/tizen_4.0_unified
(+ Major SVACE Issue : Check if dynamically allocated pointer is not NULL)
Signed-off-by: Segwon <segwon.han@samsung.com>
Change-Id: Ie844e751b1a3dabe4bb2075b081cd0180439759f
-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 | 41 |
4 files changed, 55 insertions, 29 deletions
@@ -16,7 +16,7 @@ #include "main.h" -appdata_s *ad; +appdata_s *ad = NULL; static void win_delete_request_cb(void *data, Evas_Object *obj, void *event_info) { @@ -93,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..0a603e3 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) { @@ -157,14 +166,18 @@ 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) { + 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 +185,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; |