Coverity bug fix 99/260899/2 accepted/tizen/unified/20210707.070918 submit/tizen/20210706.125104
authorrohit singh <rohit.singh@samsung.com>
Tue, 6 Jul 2021 10:14:28 +0000 (15:44 +0530)
committerrohit singh <rohit.singh@samsung.com>
Tue, 6 Jul 2021 11:37:04 +0000 (17:07 +0530)
This patch fixes:
 - Out of bound access warning
 - Resource leak warning

Change-Id: I94523d40e627acdb964b42984c8f3fe0b7035642
Signed-off-by: rohit.singh <rohit.singh@samsung.com>
src/user-awareness-event-handler.c
src/user-awareness-monitors.c

index 7cc47e55dabf13a66d7f405d3ffb35d4f8fcc521..c350b7f124d7faa4f2c025f27588aafb67f21d0d 100755 (executable)
@@ -133,6 +133,8 @@ static void __ua_event_handler(int event, uam_event_data_s *event_param,
                                event_data->account, device_info,
                                event_data->device_id);
                g_free(sensor_info);
+               g_free(device_info);
+
 
                break;
        }
index 35d0edcf81191968d5789d99d67d243c19469eca..9a9dc8a1dfc6a9fa5746bdb97370308182d1f929 100755 (executable)
@@ -1040,7 +1040,8 @@ void _ua_monitor_handle_user_location_detected(
        bitmask = sensor_info->bitmask;
 
        location_info = _uam_to_ua_location_info(device_info);
-       ret_if(NULL == location_info);
+       if(NULL == location_info)
+               goto done;
 
        for (l = ua_monitor_list; l; l = g_slist_next(l)) {
                ua_monitor_s *monitor = l->data;
@@ -1057,6 +1058,7 @@ void _ua_monitor_handle_user_location_detected(
                                account, location_info, device_id);
                }
        }
+done:
        _ua_free_sensor_info(sensor_info);
        g_free(location_info);
 
@@ -1625,9 +1627,9 @@ int ua_monitor_start_presence_detection(
 
        if (!monitor->service) {
                if (service == NULL)
-                       monitor->service = g_strndup(UA_SERVICE_DEFAULT, UA_MAX_SERVICE_LEN);
+                       monitor->service = g_strdup(UA_SERVICE_DEFAULT);
                else
-                       monitor->service = g_strndup(service, UA_MAX_SERVICE_LEN);
+                       monitor->service = g_strdup(service);
        }
        if (UA_ERROR_NONE != _ua_get_error_code(
                                _uam_get_available_sensors(&available_sensors)))
@@ -1711,9 +1713,9 @@ int ua_monitor_start_absence_detection(
 
        if (!monitor->service) {
                if (service == NULL)
-                       monitor->service = g_strndup(UA_SERVICE_DEFAULT, UA_MAX_SERVICE_LEN);
+                       monitor->service = g_strdup(UA_SERVICE_DEFAULT);
                else
-                       monitor->service = g_strndup(service, UA_MAX_SERVICE_LEN);
+                       monitor->service = g_strdup(service);
        }
 
        if (UA_ERROR_NONE != _ua_get_error_code(
@@ -1795,11 +1797,9 @@ int ua_monitor_start_location_detection(
 
        if (!monitor->service) {
                if (service == NULL)
-                       monitor->service = g_strndup(UA_SERVICE_DEFAULT,
-                                                       UA_MAX_SERVICE_LEN);
+                       monitor->service = g_strdup(UA_SERVICE_DEFAULT);
                else
-                       monitor->service = g_strndup(service,
-                                               UA_MAX_SERVICE_LEN);
+                       monitor->service = g_strdup(service);
        }
 
        if (UA_ERROR_NONE != _ua_get_error_code(