summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorSegwon <segwon.han@samsung.com>2017-08-07 12:00:56 +0900
committerSegwon <segwon.han@samsung.com>2017-08-07 12:01:55 +0900
commit833b30e4662ffb3d4435183c91c00b34c746327e (patch)
tree5b3c7d20e08a4b2b88a0970bbf5aa6766d011f2c
parent5631cfa6851b05c238f4f533ec6fead304690a92 (diff)
downloadd2d-conv-setting-tizen_3.0.tar.gz
d2d-conv-setting-tizen_3.0.tar.bz2
d2d-conv-setting-tizen_3.0.zip
(+ Major SVACE Issue : Check if dynamically allocated pointer is not NULL) Signed-off-by: Segwon <segwon.han@samsung.com> Change-Id: I899645e4ec86484b9b5753c2b8f6cafb6a699fe7
-rw-r--r--src/ui/setting_item_device_list.c81
1 files changed, 43 insertions, 38 deletions
diff --git a/src/ui/setting_item_device_list.c b/src/ui/setting_item_device_list.c
index 40ef472..866773d 100644
--- a/src/ui/setting_item_device_list.c
+++ b/src/ui/setting_item_device_list.c
@@ -118,6 +118,9 @@ static void device_list_select_cb(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->list_type = info->list_type;
selected_device->name = info->name;
@@ -247,11 +250,17 @@ static char* device_info_text_cb(void *data, Evas_Object *obj, const char *part)
}
}
+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) {
@@ -268,7 +277,7 @@ static void discovery_foreach_cb(conv_device_h device_h, int result, void *data)
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;
+ return;
}
int device_id_index;
@@ -279,31 +288,23 @@ static void discovery_foreach_cb(conv_device_h device_h, int result, void *data)
int index;
for (index = 0; index <= discovered_devices_index; index++) {
if (!strcmp(discovered_devices_info[index]->mac_address, device_id)) {
- goto MEMORY_FREE;
+ return;
}
}
- index = ++discovered_devices_index;
+ index = discovered_devices_index + 1;
discovered_devices_info[index] = (device_info_s *) calloc(sizeof(device_info_s), 1);
- discovered_devices_info[index]->list_type = LIST_TYPE_DISCOVERED;
- discovered_devices_info[index]->index = index;
- discovered_devices_info[index]->name = strdup(device_name);
- discovered_devices_info[index]->type = strdup(device_type);
- discovered_devices_info[index]->mac_address = strdup(device_id);
-
- 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);
+ if (discovered_devices_info[index] != NULL) {
+ discovered_devices_info[index]->list_type = LIST_TYPE_DISCOVERED;
+ discovered_devices_info[index]->index = index;
+ discovered_devices_info[index]->name = strdup(device_name);
+ discovered_devices_info[index]->type = strdup(device_type);
+ discovered_devices_info[index]->mac_address = strdup(device_id);
+ discovered_devices_index++;
+ 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);
}
+
return;
case CONV_DISCOVERY_RESULT_FINISHED :
@@ -390,24 +391,28 @@ static void acl_device_info(char *mac_address, char *device_type, char *device_n
if(access_control_state == 0) {
int index = ++permitted_devices_index;
permitted_devices_info[index] = (device_info_s *) calloc(sizeof(device_info_s), 1);
- permitted_devices_info[index]->list_type = LIST_TYPE_PERMITTED;
- permitted_devices_info[index]->index = index;
- permitted_devices_info[index]->name = strdup(device_name);
- permitted_devices_info[index]->type = strdup(device_type);
- permitted_devices_info[index]->mac_address = strdup(mac_address);
- elm_genlist_item_append(permitted_list, device_item_builder, permitted_devices_info[index], permitted_device_group, ELM_GENLIST_ITEM_NONE, device_list_select_cb, permitted_devices_info[index]);
- elm_genlist_item_fields_update(permitted_device_group, "elm.swallow.end", ELM_GENLIST_ITEM_FIELD_CONTENT);
+ if (permitted_devices_info[index] != NULL) {
+ permitted_devices_info[index]->list_type = LIST_TYPE_PERMITTED;
+ permitted_devices_info[index]->index = index;
+ permitted_devices_info[index]->name = strdup(device_name);
+ permitted_devices_info[index]->type = strdup(device_type);
+ permitted_devices_info[index]->mac_address = strdup(mac_address);
+ elm_genlist_item_append(permitted_list, device_item_builder, permitted_devices_info[index], permitted_device_group, ELM_GENLIST_ITEM_NONE, device_list_select_cb, permitted_devices_info[index]);
+ elm_genlist_item_fields_update(permitted_device_group, "elm.swallow.end", ELM_GENLIST_ITEM_FIELD_CONTENT);
+ }
} else if (access_control_state == 1) {
int index = ++denied_devices_index;
denied_devices_info[index] = (device_info_s *) calloc(sizeof(device_info_s), 1);
- denied_devices_info[index]->list_type = LIST_TYPE_DENIED;
- denied_devices_info[index]->index = index;
- denied_devices_info[index]->name = strdup(device_name);
- denied_devices_info[index]->type = strdup(device_type);
- denied_devices_info[index]->mac_address = strdup(mac_address);
- elm_genlist_item_append(denied_list, device_item_builder, denied_devices_info[index], denied_device_group, ELM_GENLIST_ITEM_NONE, device_list_select_cb, denied_devices_info[index]);
- elm_genlist_item_fields_update(denied_device_group, "elm.swallow.end", ELM_GENLIST_ITEM_FIELD_CONTENT);
+ if (denied_devices_info[index] != NULL) {
+ denied_devices_info[index]->list_type = LIST_TYPE_DENIED;
+ denied_devices_info[index]->index = index;
+ denied_devices_info[index]->name = strdup(device_name);
+ denied_devices_info[index]->type = strdup(device_type);
+ denied_devices_info[index]->mac_address = strdup(mac_address);
+ elm_genlist_item_append(denied_list, device_item_builder, denied_devices_info[index], denied_device_group, ELM_GENLIST_ITEM_NONE, device_list_select_cb, denied_devices_info[index]);
+ elm_genlist_item_fields_update(denied_device_group, "elm.swallow.end", ELM_GENLIST_ITEM_FIELD_CONTENT);
+ }
}
}