[epiphany/mcatanzaro/#1092] session: keep window alive when parsing session



commit 07e64e4fe21b168ef9c59ea063b3174929140e76
Author: Michael Catanzaro <mcatanzaro gnome org>
Date:   Sun Feb 9 12:41:02 2020 -0600

    session: keep window alive when parsing session
    
    This is a second try at 32ecc861. This time, account for the possibility
    of an invalid session state file, and avoid leaking the EphyWindow (it's
    unset in session_end_element()).
    
    See: #1092

 src/ephy-session.c | 19 +++++++++++++++++--
 1 file changed, 17 insertions(+), 2 deletions(-)
---
diff --git a/src/ephy-session.c b/src/ephy-session.c
index 3a4139736..b72e51913 100644
--- a/src/ephy-session.c
+++ b/src/ephy-session.c
@@ -1100,6 +1100,11 @@ session_parser_context_free (SessionParserContext *context)
 {
   g_object_unref (context->session);
 
+  if (context->window) {
+    g_warning ("Malformed session state: window tag not closed");
+    g_object_unref (context->window);
+  }
+
   g_free (context);
 }
 
@@ -1111,7 +1116,12 @@ session_parse_window (SessionParserContext  *context,
   GdkRectangle geometry = { -1, -1, 0, 0 };
   guint i;
 
-  context->window = ephy_window_new ();
+  if (context->window) {
+    g_warning ("Malformed session state: window tag inside window tag");
+    return;
+  }
+
+  context->window = EPHY_WINDOW (g_object_ref (ephy_window_new ()));
 
   for (i = 0; names[i]; i++) {
     gulong int_value;
@@ -1154,6 +1164,11 @@ session_parse_embed (SessionParserContext  *context,
   gboolean is_pin = FALSE;
   guint i;
 
+  if (!context->window) {
+    g_warning ("Malformed session state: embed tag outside window tag");
+    return;
+  }
+
   notebook = ephy_window_get_notebook (context->window);
 
   for (i = 0; names[i]; i++) {
@@ -1297,7 +1312,7 @@ session_end_element (GMarkupParseContext  *ctx,
 
     ephy_embed_shell_restored_window (shell);
 
-    context->window = NULL;
+    g_clear_object (&context->window);
     context->active_tab = 0;
     context->is_first_window = FALSE;
   } else if (strcmp (element_name, "embed") == 0) {


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