[epiphany/mcatanzaro/webapp-crashes: 2/2] Assert webapp is non-NULL where required



commit 700cec9ae69c0e9ba28d5fdf45b0fd56d6e697ff
Author: Michael Catanzaro <mcatanzaro gnome org>
Date:   Wed Apr 29 17:23:06 2020 -0500

    Assert webapp is non-NULL where required
    
    ephy_web_application_for_profile_directory() had better not return NULL
    if called for the current profile directory in app mode. In this case,
    we should crash as cleanly as possible, with g_assert().
    
    But in other situatitons, it's OK for this function to return NULL.
    Other callers are already prepared to handle this.

 lib/ephy-web-app-utils.c | 2 ++
 src/prefs-dialog.c       | 1 +
 2 files changed, 3 insertions(+)
---
diff --git a/lib/ephy-web-app-utils.c b/lib/ephy-web-app-utils.c
index 10b30ae20..3d2c66ee5 100644
--- a/lib/ephy-web-app-utils.c
+++ b/lib/ephy-web-app-utils.c
@@ -799,6 +799,8 @@ ephy_web_application_is_uri_allowed (const char *uri)
   guint i;
   gboolean matched = FALSE;
 
+  g_assert (webapp);
+
   if (g_str_has_prefix (uri, "blob:") || g_str_has_prefix (uri, "data:"))
     return TRUE;
 
diff --git a/src/prefs-dialog.c b/src/prefs-dialog.c
index 02805bc5a..fa2dc6d03 100644
--- a/src/prefs-dialog.c
+++ b/src/prefs-dialog.c
@@ -2082,6 +2082,7 @@ setup_general_page (PrefsDialog *dialog)
 
   if (ephy_embed_shell_get_mode (ephy_embed_shell_get_default ()) == EPHY_EMBED_SHELL_MODE_APPLICATION) {
     dialog->webapp = ephy_web_application_for_profile_directory (ephy_profile_dir ());
+    g_assert (dialog->webapp);
     prefs_dialog_update_webapp_icon (dialog, dialog->webapp->icon_url);
     gtk_entry_set_text (GTK_ENTRY (dialog->webapp_url), dialog->webapp->url);
     gtk_entry_set_text (GTK_ENTRY (dialog->webapp_title), dialog->webapp->name);


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