Fix issues reported by static analyzer
[apps/native/ug-wifi-direct.git] / ug-wifidirect / src / wfd_ug.c
index cd21c29..cee643e 100644 (file)
@@ -310,15 +310,15 @@ static void *on_create(ui_gadget_h ug, enum ug_mode mode, app_control_h control,
                if (ret == APP_CONTROL_ERROR_NONE && wfds) {
                        DBG_SECURE(LOG_INFO, "Wfds name: %s", wfds);
                        ugd->wfds = strdup(wfds);
-                       WFD_IF_FREE_MEM(wfds);
                }
+               WFD_IF_FREE_MEM(wfds);
 
                ret = app_control_get_extra_data(control, "viewtype", &viewtype);
                if (ret == APP_CONTROL_ERROR_NONE && viewtype) {
                        DBG(LOG_INFO, "viewtype: %s\n", viewtype);
                        ugd->view_type = strdup(viewtype);
-                       WFD_IF_FREE_MEM(viewtype);
                }
+               WFD_IF_FREE_MEM(viewtype);
 
                /*
                * get the device filter
@@ -351,9 +351,8 @@ static void *on_create(ui_gadget_h ug, enum ug_mode mode, app_control_h control,
                                ugd->device_filter = WFD_DEVICE_TYPE_AUDIO;
                        else
                                ugd->device_filter = WFD_DEVICE_TYPE_OTHER;
-
-                       WFD_IF_FREE_MEM(device_filter);
                }
+               WFD_IF_FREE_MEM(device_filter);
 
                /*
                * get whether support auto exit after connection
@@ -366,9 +365,8 @@ static void *on_create(ui_gadget_h ug, enum ug_mode mode, app_control_h control,
                                ugd->is_auto_exit = true;
                        else
                                ugd->is_auto_exit = false;
-
-                       WFD_IF_FREE_MEM(auto_exit);
                }
+               WFD_IF_FREE_MEM(auto_exit);
 
                /*
                * get whether support multi connection,
@@ -381,9 +379,8 @@ static void *on_create(ui_gadget_h ug, enum ug_mode mode, app_control_h control,
                                ugd->is_multi_connect = false;
                        else
                                ugd->is_multi_connect = true;
-
-                       WFD_IF_FREE_MEM(multi_connect);
                }
+               WFD_IF_FREE_MEM(multi_connect);
 
                /*
                * get the title of UG
@@ -394,8 +391,8 @@ static void *on_create(ui_gadget_h ug, enum ug_mode mode, app_control_h control,
                        DBG(LOG_INFO, "Title of UG: %s", title);
                        WFD_IF_FREE_MEM(ugd->title);
                        ugd->title = strdup(title);
-                       WFD_IF_FREE_MEM(title);
                }
+               WFD_IF_FREE_MEM(title);
        }
 
        if (mode == UG_MODE_FULLVIEW)