[tracker/wip/carlosg/serialize-api: 12/13] libtracker-data: Add missing locking to cursor API




commit b11818e696e6f16b281a33bcebf800d06aba5d69
Author: Carlos Garnacho <carlosg gnome org>
Date:   Wed Feb 2 02:17:57 2022 +0100

    libtracker-data: Add missing locking to cursor API
    
    This is using a sqlite3_stmt without locking the DB interface, which
    is not usually a good idea.

 src/libtracker-data/tracker-db-interface-sqlite.c | 7 +++++++
 1 file changed, 7 insertions(+)
---
diff --git a/src/libtracker-data/tracker-db-interface-sqlite.c 
b/src/libtracker-data/tracker-db-interface-sqlite.c
index 24ea5a75c..54c72345d 100644
--- a/src/libtracker-data/tracker-db-interface-sqlite.c
+++ b/src/libtracker-data/tracker-db-interface-sqlite.c
@@ -3461,13 +3461,20 @@ db_cursor_iter_next (TrackerDBCursor *cursor,
 guint
 tracker_db_cursor_get_n_columns (TrackerDBCursor *cursor)
 {
+       TrackerDBInterface *iface;
        guint n_columns;
 
+       iface = cursor->ref_stmt->db_interface;
+
+       tracker_db_interface_lock (iface);
+
        if (cursor->n_columns == 0)
                n_columns = sqlite3_column_count (cursor->stmt);
        else
                n_columns = cursor->n_columns;
 
+       tracker_db_interface_unlock (iface);
+
        return n_columns;
 }
 


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