[tracker/wip/carlosg/coverity-fixes: 6/16] libtracker-data: Check return value of g_mkdir_with_parents()




commit 1309e11da21ea7e435e096c0f82df23860445ba1
Author: Carlos Garnacho <carlosg gnome org>
Date:   Sat Oct 23 13:33:59 2021 +0200

    libtracker-data: Check return value of g_mkdir_with_parents()
    
    And raise an error if it does fail.
    
    CID: #1501143

 src/libtracker-data/tracker-db-manager.c | 9 ++++++++-
 1 file changed, 8 insertions(+), 1 deletion(-)
---
diff --git a/src/libtracker-data/tracker-db-manager.c b/src/libtracker-data/tracker-db-manager.c
index 75472188b..79e0d6ffd 100644
--- a/src/libtracker-data/tracker-db-manager.c
+++ b/src/libtracker-data/tracker-db-manager.c
@@ -585,7 +585,14 @@ tracker_db_manager_new (TrackerDBManagerFlags   flags,
                if ((flags & TRACKER_DB_MANAGER_READONLY) == 0) {
 
                        /* Make sure the directories exist */
-                       g_mkdir_with_parents (db_manager->data_dir, 00755);
+                       if (g_mkdir_with_parents (db_manager->data_dir, 00755) < 0) {
+                               g_set_error (error,
+                                            TRACKER_DB_INTERFACE_ERROR,
+                                            TRACKER_DB_OPEN_ERROR,
+                                            "Could not create database directory");
+                               g_object_unref (db_manager);
+                               return NULL;
+                       }
                }
        } else {
                db_manager->shared_cache_key = tracker_generate_uuid (NULL);


[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]