Fix crash issue
authorsaerome.kim <saerome.kim@samsung.com>
Thu, 21 Nov 2019 08:33:14 +0000 (17:33 +0900)
committersaerome.kim <saerome.kim@samsung.com>
Thu, 21 Nov 2019 23:47:05 +0000 (08:47 +0900)
- Problem: A crash may occur in a multi-client environment.
- Cause: A crash may occur if a request is deleted in the middle while
  processing the async request included in the list.
- Solution: Modified so that the list is not broken by deleting the request
  while processing the request.

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

index 6a915d3..e70cfd3 100644 (file)
@@ -1,6 +1,6 @@
 Name:       ua-manager
 Summary:    User awareness manager
-Version:    0.13.4
+Version:    0.13.5
 Release:    1
 License:    Apache-2.0
 Source0:    %{name}-%{version}.tar.gz
index 94fa9a3..118dcc1 100644 (file)
@@ -2518,7 +2518,6 @@ int _uam_core_handle_device_added(int status,
                dev = info->data;
                if (!dev) {
                        UAM_WARN("info->data is NULL");
-                       _uam_manager_remove_req_ctxt_from_list(info);
                        continue;
                }
 
@@ -2526,15 +2525,17 @@ int _uam_core_handle_device_added(int status,
                                strcasecmp(dev->device_id, dev_info->device_id)) {
                        UAM_WARN("[%d != %d] || [%s != %s]", dev->type, dev_info->type,
                                        dev->device_id, dev_info->device_id);
-                       _uam_manager_remove_req_ctxt_from_list(info);
                        continue;
                }
 
                out_param = g_array_new(FALSE, FALSE, sizeof(gchar));
                g_array_append_vals(out_param, dev_info, sizeof(uam_device_info_s));
                _uam_manager_method_return(info->context, out_param, status);
-               g_free(info->data);
+
+               _uam_remove_timer(info->tid);
+
                _uam_manager_remove_req_ctxt_from_list(info);
+
                break;
        }
 
index c69792a..d0d59e3 100644 (file)
@@ -1119,13 +1119,25 @@ void _uam_manager_remove_req_ctxt_from_list(uam_request_context_t *req_info)
                GSList *next = l->next;
                uam_request_context_t *info = l->data;
 
-               if (NULL == info || NULL == info->sender)
+               if (NULL == info) {
+                       request_list = g_slist_remove_link(request_list, l);
+                       l = next;
                        continue;
+               }
+
+               if (NULL == info->sender) {
+                       g_free(req_info->data);
+                       g_free(req_info);
+                       request_list = g_slist_remove_link(request_list, l);
+                       l = next;
+                       continue;
+               }
 
                if ((strcasecmp(info->sender, req_info->sender) == 0) &&
                        req_info->function == info->function) {
 
                        g_free(req_info->sender);
+                       g_free(req_info->data);
                        g_free(req_info);
 
                        request_list = g_slist_remove_link(request_list, l);