Fix static analysis issues
[platform/core/appfw/pkgmgr-info.git] / src / server / database / db_handle_provider.cc
index 1e88c35..14c3f30 100644 (file)
@@ -336,12 +336,6 @@ int DBHandleProvider::UpdateCache(sqlite3* db, pid_t pid, uid_t uid, bool write,
   pkg_map_.clear();
   app_map_.clear();
 
-  GHashTable* list = g_hash_table_new(g_str_hash, g_str_equal);
-  if (list == nullptr) {
-    LOG(ERROR) << "Out of memory";
-    return PMINFO_R_ERROR;
-  }
-
   const char* dbpath = sqlite3_db_filename(db, "main");
   bool is_inmemory_db = false;
   if (dbpath == nullptr || strlen(dbpath) == 0) {
@@ -354,6 +348,12 @@ int DBHandleProvider::UpdateCache(sqlite3* db, pid_t pid, uid_t uid, bool write,
   if (!is_inmemory_db && !GetModifiedTime(dbpath, &start_time))
     return PMINFO_R_ERROR;
 
+  GHashTable* list = g_hash_table_new(g_str_hash, g_str_equal);
+  if (list == nullptr) {
+    LOG(ERROR) << "Out of memory";
+    return PMINFO_R_ERROR;
+  }
+
   pkgmgrinfo_filter_x tmp_filter = { 0, };
   int ret = pkginfo_internal_filter_get_list(db, &tmp_filter, uid_,
                                              locale.c_str(), list);