diff options
author | rohit singh <rohit.singh@samsung.com> | 2021-07-06 15:44:28 +0530 |
---|---|---|
committer | rohit singh <rohit.singh@samsung.com> | 2021-07-06 17:07:04 +0530 |
commit | 9059b7b3da9472fca8de23657ce48f7425088761 (patch) | |
tree | 98b3dcd75a76454c85c3babc3c2572df2da2897e | |
parent | 3935f6e3eb67d06bfe26e2b619cc8d71fc71f577 (diff) | |
download | user-awareness-9059b7b3da9472fca8de23657ce48f7425088761.tar.gz user-awareness-9059b7b3da9472fca8de23657ce48f7425088761.tar.bz2 user-awareness-9059b7b3da9472fca8de23657ce48f7425088761.zip |
This patch fixes:
- Out of bound access warning
- Resource leak warning
Change-Id: I94523d40e627acdb964b42984c8f3fe0b7035642
Signed-off-by: rohit.singh <rohit.singh@samsung.com>
-rwxr-xr-x | src/user-awareness-event-handler.c | 2 | ||||
-rwxr-xr-x | src/user-awareness-monitors.c | 18 |
2 files changed, 11 insertions, 9 deletions
diff --git a/src/user-awareness-event-handler.c b/src/user-awareness-event-handler.c index 7cc47e5..c350b7f 100755 --- a/src/user-awareness-event-handler.c +++ b/src/user-awareness-event-handler.c @@ -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; } diff --git a/src/user-awareness-monitors.c b/src/user-awareness-monitors.c index 35d0edc..9a9dc8a 100755 --- a/src/user-awareness-monitors.c +++ b/src/user-awareness-monitors.c @@ -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( |