summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorGergo Koteles <soyer@irl.hu>2023-05-25 13:49:28 +0200
committerChristian Rauch <rauch.christian@gmx.de>2023-06-06 21:34:53 +0000
commit73260393a97291c887e1074ab7f318e031be0ac6 (patch)
treeba8a76d2be09a75c29fb18d2995becdd29a35e69
parent82a581f130ade5b09e70c757f277320ab84615ba (diff)
libdecor_plugin_gtk fix read after frees
Set destroyed widgets to NULL to make GTK_IS_WIDGET calls safe.
-rw-r--r--src/plugins/gtk/libdecor-gtk.c10
1 files changed, 8 insertions, 2 deletions
diff --git a/src/plugins/gtk/libdecor-gtk.c b/src/plugins/gtk/libdecor-gtk.c
index 30965ad..77e64f7 100644
--- a/src/plugins/gtk/libdecor-gtk.c
+++ b/src/plugins/gtk/libdecor-gtk.c
@@ -663,8 +663,10 @@ libdecor_plugin_gtk_frame_free(struct libdecor_plugin *plugin,
/* when in SSD mode, frame_gtk->header is not a proper GTK widget */
if (!GTK_IS_WIDGET(frame_gtk->header)) return;
gtk_widget_destroy(frame_gtk->header);
+ frame_gtk->header = NULL;
if (!GTK_IS_WIDGET(frame_gtk->window)) return;
gtk_widget_destroy(frame_gtk->window);
+ frame_gtk->window = NULL;
free_border_component(&frame_gtk->headerbar);
free_border_component(&frame_gtk->shadow);
@@ -890,11 +892,15 @@ ensure_title_bar_surfaces(struct libdecor_frame_gtk *frame_gtk)
* after construction. So we just destroy and re-create them.
*/
/* avoid warning when restoring previously turned off decoration */
- if (GTK_IS_WIDGET(frame_gtk->header))
+ if (GTK_IS_WIDGET(frame_gtk->header)) {
gtk_widget_destroy(frame_gtk->header);
+ frame_gtk->header = NULL;
+ }
/* avoid warning when restoring previously turned off decoration */
- if (GTK_IS_WIDGET(frame_gtk->window))
+ if (GTK_IS_WIDGET(frame_gtk->window)) {
gtk_widget_destroy(frame_gtk->window);
+ frame_gtk->window = NULL;
+ }
frame_gtk->window = gtk_offscreen_window_new();
frame_gtk->header = gtk_header_bar_new();