Fixed potential memory leak issue and prevent crash accepted/tizen/unified/20191007.234839 submit/tizen/20191007.022831
authorsaerome.kim <saerome.kim@samsung.com>
Fri, 4 Oct 2019 09:45:56 +0000 (18:45 +0900)
committersaerome.kim <saerome.kim@samsung.com>
Mon, 7 Oct 2019 02:27:35 +0000 (11:27 +0900)
There is a process of removing the user's device in the user remove process.
At that time, the tech_info that was put in the service list was not deleted
from the list.

Change-Id: If9cb86e2684b8cb434275560f719588f5f18b4d4
Signed-off-by: saerome.kim <saerome.kim@samsung.com>
packaging/ua-manager.spec
ua-daemon/src/pm/ua-pm-util.c
ua-daemon/src/ua-manager-core.c

index 257396d..21f3c57 100644 (file)
@@ -1,6 +1,6 @@
 Name:       ua-manager
 Summary:    User awareness manager
-Version:    0.11.0
+Version:    0.11.1
 Release:    1
 License:    Apache-2.0
 Source0:    %{name}-%{version}.tar.gz
index ff8a622..bc172cb 100644 (file)
@@ -143,6 +143,11 @@ void _pm_util_uas_device_info_free(uas_device_info_t *device)
 
        g_free(device->addr_list);
 
+       if (device->payload) {
+               g_free(device->payload);
+               g_free(device->payload->duid);
+       }
+
        g_free(device);
 
        FUNC_EXIT;
index 6226e17..e0122bc 100644 (file)
@@ -105,7 +105,7 @@ static void __free_address_info(gpointer data)
 
        g_free(addr->address);
        g_free(addr);
-       addr = NULL;
+
        FUNC_EXIT;
 }
 
@@ -113,12 +113,32 @@ static void __free_dev_tech_info(gpointer data)
 {
        FUNC_ENTRY;
        uam_db_tech_info_t *tech_info = data;
+       GSList *l;
 
        ret_if(NULL == tech_info);
 
+       /* Delete the tech information from the service list that includes tech. */
+       for (l = tech_info->svc_list; NULL != l; l = g_slist_next(l)) {
+               uam_db_service_info_t *svc_info = l->data;
+
+               if (!svc_info || !svc_info->dev_techs)
+                       continue;
+
+               svc_info->dev_techs = g_slist_remove(svc_info->dev_techs, tech_info);
+       }
+
        g_slist_free_full(tech_info->addresses, __free_address_info);
+       tech_info->addresses = NULL;
+
+       if (tech_info->payload) {
+               if (tech_info->payload->duid) {
+                       g_free(tech_info->payload->duid);
+               }
+               g_free(tech_info->payload);
+       }
+
        g_free(tech_info);
-       tech_info = NULL;
+
        FUNC_EXIT;
 }
 
@@ -136,7 +156,7 @@ static void __free_user_device(gpointer data)
        g_free(device->device_id);
        g_slist_free_full(device->tech_list, __free_dev_tech_info);
        g_free(device);
-       device = NULL;
+
        FUNC_EXIT;
 }
 
@@ -246,12 +266,22 @@ static void __remove_user_device(gpointer data)
 
        for (l = device->tech_list; NULL != l; l = g_slist_next(l)) {
                uam_db_tech_info_t *tech = l->data;
-               GSList *l1;
+               GSList *l1, *l2;
                int ret;
 
                if (!tech)
                        continue;
 
+               /* Delete the tech information from the service list that includes tech. */
+               for (l2 = tech->svc_list; NULL != l2; l2 = g_slist_next(l2)) {
+                       uam_db_service_info_t *svc_info = l2->data;
+
+                       if (!svc_info || !svc_info->dev_techs)
+                               continue;
+
+                       svc_info->dev_techs = g_slist_remove(svc_info->dev_techs, tech);
+               }
+
                dev_info.type = tech->tech_type;
                memset(dev_info.mac, 0x00, UAM_MAC_ADDRESS_STRING_LEN);
                memset(dev_info.ipv4_addr, 0x00, UAM_IP_ADDRESS_MAX_STRING_LEN);