Fix issue detected by static analysis tool 26/197726/2
authorJihoon Kim <jihoon48.kim@samsung.com>
Wed, 16 Jan 2019 01:58:11 +0000 (10:58 +0900)
committerJihoon Kim <jihoon48.kim@samsung.com>
Wed, 16 Jan 2019 01:59:10 +0000 (10:59 +0900)
After having been compared to NULL value at isf_query_utility.cpp:275, pointer 'databaseInfo.pHandle' is dereferenced at isf_query_utility.cpp:286 by calling function 'sqlite3_exec'.

Change-Id: I107205f712bc4ec16f2296fbbd41d3db5bdc70e3
Signed-off-by: Jihoon Kim <jihoon48.kim@samsung.com>
ism/src/isf_query_utility.cpp

index 5d3a274..aa27c53 100644 (file)
@@ -281,11 +281,11 @@ static inline int _db_init(void)
             LOGE ("sqlite3_exec returned %d: %s", ret, pException);
             sqlite3_free(pException);
         }
-    }
 
-    if (SQLITE_CORRUPT == sqlite3_exec(databaseInfo.pHandle, "pragma integrity_check", _db_integrity_check_cb, NULL, NULL)) {
-        databaseInfo.need_reset = true;
-        LOGE ("DB has been corrupted.");
+        if (SQLITE_CORRUPT == sqlite3_exec(databaseInfo.pHandle, "pragma integrity_check", _db_integrity_check_cb, NULL, NULL)) {
+            databaseInfo.need_reset = true;
+            LOGE ("DB has been corrupted.");
+        }
     }
 
     return 0;