Fixed coverity issue. 75/213975/1
authorsungrae jo <seongrae.jo@samsung.com>
Tue, 17 Sep 2019 05:45:39 +0000 (14:45 +0900)
committersungrae jo <seongrae.jo@samsung.com>
Tue, 17 Sep 2019 05:45:39 +0000 (14:45 +0900)
Change-Id: Ide3e1362f2db573710fc2de37f393232c2d88b6e
Signed-off-by: sungrae jo <seongrae.jo@samsung.com>
common/vc_cmd_db.c
common/vc_config_mgr.c

index c866247..7823832 100644 (file)
@@ -201,6 +201,8 @@ static int __vc_db_delete_commands(sqlite3* db_handle, int pid, vc_cmd_type_e ty
                SLOG(LOG_WARN, vc_db_tag(), "[WARNING] There is no table (%s) (%d). Make a table", VC_INFO_TABLE, ret);
                if (VC_DB_ERROR_NONE != __vc_db_create_table(db_handle, VC_INFO_TABLE)) {
                        SLOG(LOG_ERROR, vc_db_tag(), "[ERROR] Fail to create table(%s), %d", VC_INFO_TABLE, ret);
+                       free(sql);
+                       sql = NULL;
                        return VC_DB_ERROR_OPERATION_FAILED;
                }
        } else {
@@ -409,6 +411,8 @@ static int __vc_db_get_commands(sqlite3* db_handle, int pid, vc_cmd_type_e type,
                SLOG(LOG_WARN, vc_db_tag(), "[WARNING] There is no table (%s) (%d). Make a table", VC_INFO_TABLE, ret);
                if (VC_DB_ERROR_NONE != __vc_db_create_table(db_handle, VC_INFO_TABLE)) {
                        SLOG(LOG_ERROR, vc_db_tag(), "[ERROR] Fail to create table(%s), %d", VC_INFO_TABLE, ret);
+                       free(sql);
+                       sql = NULL;
                        return VC_DB_ERROR_OPERATION_FAILED;
                }
        } else {
@@ -856,6 +860,8 @@ static int __vc_db_get_result(sqlite3* db_handle, char** result_text, int* event
                SLOG(LOG_WARN, vc_db_tag(), "[WARNING] There is no table (%s) (%d). Make a table", VC_RESULT_TABLE, ret);
                if (VC_DB_ERROR_NONE != __vc_db_create_table(db_handle, VC_RESULT_TABLE)) {
                        SLOG(LOG_ERROR, vc_db_tag(), "[ERROR] Fail to create table(%s), %d", VC_RESULT_TABLE, ret);
+                       free(sql);
+                       sql = NULL;
                        return VC_DB_ERROR_OPERATION_FAILED;
                }
        } else {
@@ -1432,6 +1438,8 @@ static int __vc_db_create_table(sqlite3* db_handle, const char* table)
        }
        SLOG(LOG_WARN, vc_db_tag(), "[SQL] %s", sql);
 
+       free(sql);
+       sql = NULL;
        return VC_DB_ERROR_NONE;
 }
 
index 35acf5d..4edf45b 100644 (file)
@@ -1454,7 +1454,7 @@ int vc_config_mgr_set_engine(const char* engine)
                }
 
                /* Check engine id is valid */
-               if (0 != strcmp(engine, engine_info->uuid)) {
+               if (NULL == engine_info->uuid || 0 != strcmp(engine, engine_info->uuid)) {
                        iter = g_slist_next(iter);
                        continue;
                }
@@ -1463,8 +1463,8 @@ int vc_config_mgr_set_engine(const char* engine)
                        free(g_config_info->engine_id);
                        g_config_info->engine_id = NULL;
                }
-               if (engine_info->uuid)
-                       g_config_info->engine_id = strdup(engine_info->uuid);
+
+               g_config_info->engine_id = strdup(engine_info->uuid);
 
 
                /* Engine is valid*/