From 9be580a689d1e01e2c061b0a1da6c749d83c0c2c Mon Sep 17 00:00:00 2001 From: Ross Burton Date: Thu, 26 Mar 2020 15:22:14 +0000 Subject: Check for errors from more sqlite calls Once the mapping database is opened we call 'PRAGMA synchronous', check the error code so if the database is corrupted then we can bail sooner rather than later. --- src/cd-mapping-db.c | 14 +++++++++++--- 1 file changed, 11 insertions(+), 3 deletions(-) diff --git a/src/cd-mapping-db.c b/src/cd-mapping-db.c index 1ef4560..f62e267 100644 --- a/src/cd-mapping-db.c +++ b/src/cd-mapping-db.c @@ -91,9 +91,17 @@ cd_mapping_db_load (CdMappingDb *mdb, } /* we don't need to keep doing fsync */ - sqlite3_exec (priv->db, "PRAGMA synchronous=OFF", - NULL, NULL, NULL); - + rc = sqlite3_exec (priv->db, "PRAGMA synchronous=OFF", + NULL, NULL, &error_msg); + if (rc != SQLITE_OK) { + g_set_error (error, + CD_CLIENT_ERROR, + CD_CLIENT_ERROR_INTERNAL, + "Failed to turn off synchronous operations: SQL error: %s", + error_msg); + sqlite3_free (error_msg); + return FALSE; + } /* check mappings */ rc = sqlite3_exec (priv->db, "SELECT * FROM mappings LIMIT 1", NULL, NULL, &error_msg); -- cgit v1.2.1