1
0
Fork 0

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: <https://gitlab.gnome.org/GNOME/mutter/-/merge_requests/3697>
This commit is contained in:
Sebastian Keller 2024-04-11 21:59:44 +02:00 committed by Marge Bot
parent c25f6f2ded
commit 2e38ec6ce1

View file

@ -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);