Use wrapper to free wifi handle memory 19/248319/2
authorNishant Chaprana <n.chaprana@samsung.com>
Wed, 25 Nov 2020 08:25:35 +0000 (13:55 +0530)
committerNishant Chaprana <n.chaprana@samsung.com>
Thu, 26 Nov 2020 05:28:38 +0000 (10:58 +0530)
Change-Id: I8951697392421ed0dba3190045fadbbdc8483300
Signed-off-by: Nishant Chaprana <n.chaprana@samsung.com>
include/wifi_internal.h
packaging/capi-network-wifi-manager.spec
src/wifi_internal.c
src/wifi_manager.c

index ff4d7c2..d556d53 100755 (executable)
@@ -315,6 +315,7 @@ void _wifi_set_cs_tid(wifi_manager_h wifi, int tid);
 void _wifi_unset_cs_tid(int tid);
 
 int _wifi_create_handle(wifi_manager_h *wifi);
+void _wifi_destroy_handle(wifi_manager_h wifi);
 void _wifi_add_to_handle_list(wifi_manager_h *wifi);
 void _wifi_remove_from_handle_list(wifi_manager_h wifi);
 int _wifi_length_from_handle_list(void);
index 9ddf9fb..3fb0710 100755 (executable)
@@ -1,6 +1,6 @@
 Name:          capi-network-wifi-manager
 Summary:       Network Wi-Fi library in TIZEN C API
-Version:       1.3.1
+Version:       1.3.2
 Release:       1
 Group:         System/Network
 License:       Apache-2.0
index ddbe6f2..9a8634d 100755 (executable)
@@ -1492,6 +1492,11 @@ int _wifi_create_handle(wifi_manager_h *wifi)
        return WIFI_MANAGER_ERROR_NONE;
 }
 
+void _wifi_destroy_handle(wifi_manager_h wifi)
+{
+       g_free(wifi);
+}
+
 void _wifi_add_to_handle_list(wifi_manager_h *wifi)
 {
        wifi_manager_handle_list = g_slist_append(wifi_manager_handle_list, *wifi);
@@ -1500,8 +1505,6 @@ void _wifi_add_to_handle_list(wifi_manager_h *wifi)
 void _wifi_remove_from_handle_list(wifi_manager_h wifi)
 {
        wifi_manager_handle_list = g_slist_remove(wifi_manager_handle_list, wifi);
-
-       g_free(wifi);
 }
 
 int _wifi_length_from_handle_list(void)
index 00c5d98..f6551c2 100755 (executable)
@@ -118,11 +118,13 @@ EXPORT_API int wifi_manager_initialize(wifi_manager_h *wifi)
        if (rv == NET_ERR_ACCESS_DENIED) {
                WIFI_LOG(WIFI_ERROR, "Access denied"); //LCOV_EXCL_LINE
                _wifi_deinit(*wifi); //LCOV_EXCL_LINE
+               _wifi_destroy_handle(wifi); //LCOV_EXCL_LINE
                __NETWORK_CAPI_FUNC_EXIT__; //LCOV_EXCL_LINE
                return WIFI_MANAGER_ERROR_PERMISSION_DENIED; //LCOV_EXCL_LINE
        } else if (rv != NET_ERR_NONE) {
                WIFI_LOG(WIFI_ERROR, "Init failed[%d]", rv); //LCOV_EXCL_LINE
                _wifi_deinit(*wifi); //LCOV_EXCL_LINE
+               _wifi_destroy_handle(wifi); //LCOV_EXCL_LINE
                __NETWORK_CAPI_FUNC_EXIT__; //LCOV_EXCL_LINE
                return WIFI_MANAGER_ERROR_OPERATION_FAILED; //LCOV_EXCL_LINE
        }
@@ -173,11 +175,13 @@ EXPORT_API int wifi_manager_initialize_with_interface_name(wifi_manager_h *wifi,
        if (rv == NET_ERR_ACCESS_DENIED) {
                WIFI_LOG(WIFI_ERROR, "Access denied"); //LCOV_EXCL_LINE
                _wifi_deinit(*wifi); //LCOV_EXCL_LINE
+               _wifi_destroy_handle(wifi); //LCOV_EXCL_LINE
                __NETWORK_CAPI_FUNC_EXIT__; //LCOV_EXCL_LINE
                return WIFI_MANAGER_ERROR_PERMISSION_DENIED; //LCOV_EXCL_LINE
        } else if (rv != NET_ERR_NONE) {
                WIFI_LOG(WIFI_ERROR, "Init failed[%d]", rv); //LCOV_EXCL_LINE
                _wifi_deinit(*wifi); //LCOV_EXCL_LINE
+               _wifi_destroy_handle(wifi); //LCOV_EXCL_LINE
                __NETWORK_CAPI_FUNC_EXIT__; //LCOV_EXCL_LINE
                return WIFI_MANAGER_ERROR_OPERATION_FAILED; //LCOV_EXCL_LINE
        }
@@ -202,8 +206,9 @@ EXPORT_API int wifi_manager_deinitialize(wifi_manager_h wifi)
 
        WIFI_LOG(WIFI_INFO, "Destroy handle: %p", wifi);
 
-       _wifi_deinit(wifi);
        _wifi_remove_from_handle_list(wifi);
+       _wifi_deinit(wifi);
+       _wifi_destroy_handle(wifi);
 
        if (_wifi_length_from_handle_list() == 0)
                _wifi_clear_profile_list();