Fixed svace issues. 48/212248/1
authorsaerome.kim <saerome.kim@samsung.com>
Mon, 19 Aug 2019 06:48:02 +0000 (15:48 +0900)
committersaerome.kim <saerome.kim@samsung.com>
Mon, 19 Aug 2019 08:35:28 +0000 (17:35 +0900)
386920: Added null-check routine.
300446,400466,1242348,1242352: Fixed potential memory leak problem.
1242351: Added missing null-check routine.

Change-Id: I6a64aa6dd8b51921c512c1a1242e5b7957fda097
Signed-off-by: saerome.kim <saerome.kim@samsung.com>
ua-daemon/src/ua-manager-core.c
ua-daemon/src/ua-manager-db.c

index 44dc0ef..b6d91d0 100644 (file)
@@ -1831,6 +1831,7 @@ static int __uam_core_start_detection(int detection_type,
                l = services;
        }
        service = l->data;
+       retv_if(NULL == service, UAM_ERROR_NOT_FOUND);
 
        monitor = __uam_find_monitor(monitors, sender, svc_name, detection_type);
        if (!monitor) {
index ef45259..01235a2 100644 (file)
@@ -230,7 +230,7 @@ static bool __is_table_existing(const char *table)
        int ret;
        char *sql;
        int count;
-       bool result;
+       bool result = false;
 
        sql = sqlite3_mprintf(
                "SELECT count(*) FROM sqlite_master WHERE type='table' AND name ='%s';", table);
@@ -243,13 +243,15 @@ static bool __is_table_existing(const char *table)
        ret = sqlite3_prepare_v2(database, sql, strlen(sql), &stmt, NULL);
        if (SQLITE_OK != ret) {
                UAM_ERR("sqlite3_prepare_v2 failed, [%d:%s]", ret, sqlite3_errmsg(database));
-               return false;
+               result = false;
+               goto is_table_existing_done;
        }
 
        ret = sqlite3_step(stmt);
        if (SQLITE_ROW != ret) {
                UAM_ERR("sqlite3_step failed, [%d:%s]", ret, sqlite3_errmsg(database));
-               return false;
+               result = false;
+               goto is_table_existing_done;
        }
 
        count = sqlite3_column_int(stmt, 0);
@@ -258,6 +260,7 @@ static bool __is_table_existing(const char *table)
        else
                result = false;
 
+is_table_existing_done:
        sqlite3_finalize(stmt);
        sqlite3_free(sql);