[epiphany/gnome-3-36] gsb-service: don't crash when GSB database is broken



commit 5ceac60b4d9dd685ed2823dde1ff17b45fa3f265
Author: Michael Catanzaro <mcatanzaro gnome org>
Date:   Mon Nov 23 20:22:07 2020 +0000

    gsb-service: don't crash when GSB database is broken
    
    Currently there are four places where we assert the GSB database is not
    broken. But some of these asserts are wrong. Two are clearly safe, and
    one is clearly not (since it was actually hit). I think the other is
    also not safe.
    
    https://bugzilla.redhat.com/show_bug.cgi?id=1900656
    
    
    (cherry picked from commit 3829d5687af829ef2e6ade8c77061ba052a2918a)

 lib/safe-browsing/ephy-gsb-service.c | 13 +++++++++++--
 1 file changed, 11 insertions(+), 2 deletions(-)
---
diff --git a/lib/safe-browsing/ephy-gsb-service.c b/lib/safe-browsing/ephy-gsb-service.c
index 98d23d3fa..1070c2870 100644
--- a/lib/safe-browsing/ephy-gsb-service.c
+++ b/lib/safe-browsing/ephy-gsb-service.c
@@ -141,7 +141,12 @@ ephy_gsb_service_schedule_update (EphyGSBService *self)
   gint64 interval;
 
   g_assert (EPHY_IS_GSB_SERVICE (self));
-  g_assert (ephy_gsb_storage_is_operable (self->storage));
+
+  if (!ephy_gsb_storage_is_operable (self->storage)) {
+    self->source_id = 0;
+    LOG ("Local GSB database is broken, cannot schedule update");
+    return;
+  }
 
   /* This function should only be called when self->next_list_updates_time is
    * greater than CURRENT_TIME. However, asserting (self->next_list_updates_time
@@ -178,7 +183,11 @@ ephy_gsb_service_update_thread (GTask          *task,
   char *body;
 
   g_assert (EPHY_IS_GSB_SERVICE (self));
-  g_assert (ephy_gsb_storage_is_operable (self->storage));
+
+  if (!ephy_gsb_storage_is_operable (self->storage)) {
+    LOG ("Local GSB database is broken, cannot update it");
+    goto out;
+  }
 
   /* Set up a default next update time in case of failure or non-existent
    * minimum wait duration.


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