From 2e38ec6ce16c35c05b7bccb137da1c8d938eb9bd Mon Sep 17 00:00:00 2001 From: Sebastian Keller Date: Thu, 11 Apr 2024 21:59:44 +0200 Subject: [PATCH] frame: Assume a size of 0 when extent properties are undefined Previously the function would exit early, never changing the out value which is usually passed in uninitialized. This would however only happen in the presence of another issue leading to the properties being undefined. We can still be a bit more defensive against this though. Related: https://gitlab.gnome.org/GNOME/mutter/-/issues/3404 Related: https://gitlab.gnome.org/GNOME/gtk/-/issues/6558 Part-of: --- src/core/frame.c | 22 +++++++++++++--------- 1 file changed, 13 insertions(+), 9 deletions(-) diff --git a/src/core/frame.c b/src/core/frame.c index 145f0b7bd..c74a2e04e 100644 --- a/src/core/frame.c +++ b/src/core/frame.c @@ -274,7 +274,7 @@ meta_frame_query_borders (MetaFrame *frame, int format, res; Atom type; unsigned long nitems, bytes_after; - unsigned char *data; + unsigned char *data = NULL; if (!frame->xwindow) return; @@ -290,10 +290,8 @@ meta_frame_query_borders (MetaFrame *frame, &nitems, &bytes_after, (unsigned char **) &data); - if (mtk_x11_error_trap_pop_with_return (x11_display->xdisplay) != Success) - return; - - if (res == Success && nitems == 4) + if (mtk_x11_error_trap_pop_with_return (x11_display->xdisplay) == Success && + res == Success && nitems == 4) { borders->invisible = (MetaFrameBorder) { ((long *) data)[0], @@ -302,6 +300,10 @@ meta_frame_query_borders (MetaFrame *frame, ((long *) data)[3], }; } + else + { + borders->invisible = (MetaFrameBorder) { 0, 0, 0, 0 }; + } g_clear_pointer (&data, XFree); @@ -316,10 +318,8 @@ meta_frame_query_borders (MetaFrame *frame, &nitems, &bytes_after, (unsigned char **) &data); - if (mtk_x11_error_trap_pop_with_return (x11_display->xdisplay) != Success) - return; - - if (res == Success && nitems == 4) + if (mtk_x11_error_trap_pop_with_return (x11_display->xdisplay) == Success && + res == Success && nitems == 4) { borders->visible = (MetaFrameBorder) { ((long *) data)[0], @@ -328,6 +328,10 @@ meta_frame_query_borders (MetaFrame *frame, ((long *) data)[3], }; } + else + { + borders->visible = (MetaFrameBorder) { 0, 0, 0, 0 }; + } g_clear_pointer (&data, XFree);