[tracker] libtracker-data: Guard against failure to open the database



commit 77b275e998ad44c5f87b96edbba848a169096185
Author: Debarshi Ray <debarshir gnome org>
Date:   Mon Oct 13 13:49:29 2014 +0200

    libtracker-data: Guard against failure to open the database
    
    An error from sqlite3_open_v2 will lead to a failure to create a
    TrackerDBInterface. This means that DBManager.get_db_interface will
    fail.
    
    https://bugzilla.gnome.org/show_bug.cgi?id=738450

 src/libtracker-data/tracker-sparql-query.vala |    4 ++++
 1 files changed, 4 insertions(+), 0 deletions(-)
---
diff --git a/src/libtracker-data/tracker-sparql-query.vala b/src/libtracker-data/tracker-sparql-query.vala
index b84103d..2430263 100644
--- a/src/libtracker-data/tracker-sparql-query.vala
+++ b/src/libtracker-data/tracker-sparql-query.vala
@@ -500,6 +500,10 @@ public class Tracker.Sparql.Query : Object {
 
        DBStatement prepare_for_exec (string sql) throws DBInterfaceError, Sparql.Error, DateError {
                var iface = DBManager.get_db_interface ();
+               if (iface == null) {
+                       throw new DBInterfaceError.OPEN_ERROR ("Error opening database");
+               }
+
                var stmt = iface.create_statement (no_cache ? DBStatementCacheType.NONE : 
DBStatementCacheType.SELECT, "%s", sql);
 
                // set literals specified in query


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