From 0d2646a3a0067fd7732b4d0d28569cb0209afee0 Mon Sep 17 00:00:00 2001 From: "saerome.kim" Date: Mon, 26 Aug 2019 18:08:05 +0900 Subject: [PATCH] Fixed the Coverity and Svace issues. 1078581 Dereferencing null pointer tech. 1078570 leaked_storage: Variable 'app' going out of scope leaks the storage it points to. 386920 leaked_storage: Variable 'mac' going out of scope leaks the storage it points to. Change-Id: I8dee929466df35ec1e577770846c9423a2ba895e Signed-off-by: saerome.kim --- packaging/ua-manager.spec | 2 +- ua-daemon/src/ua-manager-core.c | 9 +++++---- ua-daemon/src/ua-manager-event-sender.c | 1 + 3 files changed, 7 insertions(+), 5 deletions(-) diff --git a/packaging/ua-manager.spec b/packaging/ua-manager.spec index 2918c09..67bb387 100644 --- a/packaging/ua-manager.spec +++ b/packaging/ua-manager.spec @@ -1,6 +1,6 @@ Name: ua-manager Summary: User awareness manager -Version: 0.6.10 +Version: 0.6.11 Release: 1 License: Apache-2.0 Source0: %{name}-%{version}.tar.gz diff --git a/ua-daemon/src/ua-manager-core.c b/ua-daemon/src/ua-manager-core.c index 466850f..b4dcc60 100644 --- a/ua-daemon/src/ua-manager-core.c +++ b/ua-daemon/src/ua-manager-core.c @@ -1754,9 +1754,11 @@ static int __uam_core_start_detection(int detection_type, services = g_slist_append(services, default_svc); l = services; } - service = l->data; - retv_if(NULL == service, UAM_ERROR_NOT_FOUND); + retv_if(NULL == l, UAM_ERROR_NOT_FOUND); + retv_if(NULL == l->data, UAM_ERROR_INTERNAL); + + service = l->data; monitor = __uam_find_monitor(monitors, sender, svc_name, detection_type); if (!monitor) { monitor = g_malloc0(sizeof(uam_monitor_info_t)); @@ -2422,8 +2424,7 @@ static void __send_user_absence_event(uam_tech_type_e type, unsigned int sensor) uam_db_tech_info_t *tech = l1->data; if (!tech || (tech->tech_type != type)) { - UAM_WARN("tech is NULL or tech->tech_type [%d] != type [%d]", - tech->tech_type, type); + UAM_WARN("tech is NULL or tech->tech_type != type [%d]", type); continue; } diff --git a/ua-daemon/src/ua-manager-event-sender.c b/ua-daemon/src/ua-manager-event-sender.c index b55ac47..f7cbdf4 100644 --- a/ua-daemon/src/ua-manager-event-sender.c +++ b/ua-daemon/src/ua-manager-event-sender.c @@ -252,6 +252,7 @@ int _uam_register_app_info(char *sender, uam_app_info_s app_info) app->sender = g_strdup(sender); if (!app->sender) { UAM_ERR("Failed allocated memory"); + g_free(app); return UAM_ERROR_OUT_OF_MEMORY; } g_strlcpy(app->app_id, app_info.app_id, UAM_APP_ID_MAX_STRING_LEN); -- 2.7.4