summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorMichael Catanzaro <mcatanzaro@redhat.com>2023-01-04 09:44:04 -0600
committerMarge Bot <marge-bot@gnome.org>2023-01-05 00:25:27 +0000
commit0d8f3480db9a08e8ff4cc62ddd89fd9b1c810f8c (patch)
treecd38f1a1217959cfa30087430e56cdec7d5e9015
parent048d520594c21aaaf21be900ead85e3305074798 (diff)
downloadepiphany-0d8f3480db9a08e8ff4cc62ddd89fd9b1c810f8c.tar.gz
Remove ephy_gui_ensure_window_group()
Coverity discovered a use-after-free in ephy_gui_ensure_window_group(), where the newly-created GtkWindowGroup is freed immediately before it is returned. This could only possibly make sense if GtkWindowGroup has very weird refcounting semantics, but there is no indication of this in its documentation. Fortunately, the buggy code is unreachable because it only occurs if gtk_window_get_group() returns NULL, which is impossible because the function is not nullable. It will always return the default window group, not NULL. This means the entire condition can be removed, so ephy_gui_ensure_window_group() can be simplified to just return gtk_window_get_group() without changing behavior. But none of the callers actually look at the return value. And gtk_window_get_group() has no side-effects, so it does not "ensure" anything. Therefore all of this code is doing nothing, and can be safely removed. Part-of: <https://gitlab.gnome.org/GNOME/epiphany/-/merge_requests/1256>
-rw-r--r--lib/ephy-gui.c15
-rw-r--r--lib/ephy-gui.h2
-rw-r--r--src/ephy-history-dialog.c2
-rw-r--r--src/ephy-window.c2
-rw-r--r--src/preferences/ephy-prefs-dialog.c2
5 files changed, 0 insertions, 23 deletions
diff --git a/lib/ephy-gui.c b/lib/ephy-gui.c
index a35eb2ec2..8a098b6b2 100644
--- a/lib/ephy-gui.c
+++ b/lib/ephy-gui.c
@@ -24,21 +24,6 @@
#include <glib/gi18n.h>
#include <gtk/gtk.h>
-GtkWindowGroup *
-ephy_gui_ensure_window_group (GtkWindow *window)
-{
- GtkWindowGroup *group;
-
- group = gtk_window_get_group (window);
- if (group == NULL) {
- group = gtk_window_group_new ();
- gtk_window_group_add_window (group, window);
- g_object_unref (group);
- }
-
- return group;
-}
-
/**
* ephy_gui_help:
* @parent: the parent window where help is being called
diff --git a/lib/ephy-gui.h b/lib/ephy-gui.h
index 46c397d2e..a24cb46c6 100644
--- a/lib/ephy-gui.h
+++ b/lib/ephy-gui.h
@@ -24,8 +24,6 @@
G_BEGIN_DECLS
-GtkWindowGroup *ephy_gui_ensure_window_group (GtkWindow *window);
-
void ephy_gui_help (GtkWidget *parent,
const char *page);
diff --git a/src/ephy-history-dialog.c b/src/ephy-history-dialog.c
index 868002f90..c51b705ca 100644
--- a/src/ephy-history-dialog.c
+++ b/src/ephy-history-dialog.c
@@ -1028,8 +1028,6 @@ ephy_history_dialog_init (EphyHistoryDialog *self)
gtk_search_bar_connect_entry (GTK_SEARCH_BAR (self->search_bar),
GTK_EDITABLE (self->search_entry));
- ephy_gui_ensure_window_group (GTK_WINDOW (self));
-
if (ephy_embed_shell_get_mode (shell) == EPHY_EMBED_SHELL_MODE_INCOGNITO) {
tooltip = _("It is not possible to modify history when in incognito mode.");
set_can_clear (self, FALSE);
diff --git a/src/ephy-window.c b/src/ephy-window.c
index 49521c18a..5e8fec0f2 100644
--- a/src/ephy-window.c
+++ b/src/ephy-window.c
@@ -3604,8 +3604,6 @@ ephy_window_constructed (GObject *object)
g_signal_connect (window, "notify::fullscreened",
G_CALLBACK (notify_fullscreen_cb), NULL);
- ephy_gui_ensure_window_group (GTK_WINDOW (window));
-
window->tab_view = setup_tab_view (window);
window->tab_bar = adw_tab_bar_new ();
window->tab_bar_revealer = GTK_REVEALER (gtk_revealer_new ());
diff --git a/src/preferences/ephy-prefs-dialog.c b/src/preferences/ephy-prefs-dialog.c
index adf453c6f..208c84574 100644
--- a/src/preferences/ephy-prefs-dialog.c
+++ b/src/preferences/ephy-prefs-dialog.c
@@ -153,8 +153,6 @@ ephy_prefs_dialog_init (EphyPrefsDialog *dialog)
gtk_widget_init_template (GTK_WIDGET (dialog));
gtk_window_set_icon_name (GTK_WINDOW (dialog), APPLICATION_ID);
- ephy_gui_ensure_window_group (GTK_WINDOW (dialog));
-
sync_extensions (dialog);
g_signal_connect_object (EPHY_SETTINGS_WEB,
"changed::" EPHY_PREFS_WEB_ENABLE_WEBEXTENSIONS,