Fix svace issue 26/173226/2
authorSeonah Moon <seonah1.moon@samsung.com>
Tue, 20 Mar 2018 05:32:00 +0000 (14:32 +0900)
committerSeonah Moon <seonah1.moon@samsung.com>
Tue, 20 Mar 2018 05:36:32 +0000 (14:36 +0900)
WGID-328327

Change-Id: I797fad91a019e1ea666c57e55be5073f65ba9040

packaging/download-provider.spec
provider/download-provider-db.c

index 18146b3..590b880 100755 (executable)
@@ -1,6 +1,6 @@
 Name:       download-provider
 Summary:    Download the contents in background
-Version:    2.1.92
+Version:    2.1.93
 Release:    0
 Group:      Development/Libraries
 License:    Apache-2.0
index 0cf3cc9..ccc05e1 100755 (executable)
@@ -50,6 +50,7 @@ static void __dp_finalize(sqlite3_stmt *stmt)
 static int __check_integrity(sqlite3 *handle)
 {
        sqlite3_stmt *stmt = NULL;
+       int ret = 0;
 
        if (handle == 0) {
                TRACE_ERROR("failed to check handle");
@@ -57,26 +58,23 @@ static int __check_integrity(sqlite3 *handle)
        }
 
        TRACE_INFO("");
-       int ret = sqlite3_prepare_v2(handle, "PRAGMA integrity_check", -1, &stmt, NULL);
-       if (ret != SQLITE_OK && ret != SQLITE_BUSY) {
+       int errorcode = sqlite3_prepare_v2(handle, "PRAGMA integrity_check", -1, &stmt, NULL);
+       if (errorcode != SQLITE_OK && errorcode != SQLITE_BUSY) {
                TRACE_ERROR("failed to check integrity:%s", sqlite3_errmsg(handle));
-               return -1;
+               ret = -1;
        } else {
-               ret = sqlite3_step(stmt);
-               if (ret == SQLITE_ROW) {
+               errorcode = sqlite3_step(stmt);
+               if (errorcode == SQLITE_ROW) {
                        const char *ret_val = (const char *)sqlite3_column_text(stmt, 0);
                        TRACE_INFO("ret_val: %s", ret_val);
-                       if (ret_val && strcmp(ret_val, "ok") == 0) {
-                               return 0;
-                       } else {
+                       if (!ret_val || strcmp(ret_val, "ok") != 0) {
                                TRACE_ERROR("failed to check integrity");
-                               return -1;
+                               ret = -1;
                        }
-               } else {
-                       return 0;
                }
        }
-       return 0;
+       __dp_finalize(stmt);
+       return ret;
 }
 
 static int __check_table(sqlite3 *handle, char *table)