Fix resource leak that occur when getting IP 40/282340/1
authorJaehyun Kim <jeik01.kim@samsung.com>
Fri, 30 Sep 2022 03:40:06 +0000 (12:40 +0900)
committerJaehyun Kim <jeik01.kim@samsung.com>
Fri, 30 Sep 2022 03:40:06 +0000 (12:40 +0900)
Change-Id: I7ad65f496f8d172f5b8edbb943cce773a1340c67
Signed-off-by: Jaehyun Kim <jeik01.kim@samsung.com>
include/wifi-manager.h
src/wifi_ap.c

index 8c81d49..7771739 100644 (file)
@@ -2516,6 +2516,7 @@ int wifi_manager_ap_set_ip_config_type(wifi_manager_ap_h ap,
  * @retval #WIFI_MANAGER_ERROR_INVALID_PARAMETER    Invalid parameter
  * @retval #WIFI_MANAGER_ERROR_OUT_OF_MEMORY        Out of memory
  * @retval #WIFI_MANAGER_ERROR_ADDRESS_FAMILY_NOT_SUPPORTED  Address family not supported
+ * @retval #WIFI_MANAGER_ERROR_NO_CONNECTION        There is no connected AP
  * @retval #WIFI_MANAGER_ERROR_NOT_SUPPORTED        Not supported
  * @see  wifi_manager_ap_foreach_ipv6_address()
  */
index 0fbfd69..a4c6c3e 100644 (file)
@@ -945,6 +945,10 @@ EXPORT_API int wifi_manager_ap_get_ip_address(wifi_manager_ap_h ap,
                                address_family);
                if (g_strcmp0(*ip_address, "0.0.0.0") == 0) {
                        WIFI_LOG(WIFI_ERROR, "Invalid IP Address [%s]", *ip_address); //LCOV_EXCL_LINE
+
+                       g_free(*ip_address);
+                       *ip_address = NULL;
+
                        __NETWORK_CAPI_FUNC_EXIT__; //LCOV_EXCL_LINE
                        return WIFI_MANAGER_ERROR_NO_CONNECTION; //LCOV_EXCL_LINE
                }