Skip to content

Commit af71a8e

Browse files
authored
[Wayland] Fix crash when empty window geometry set (#741)
Backported from https://gitlab.gnome.org/GNOME/mutter/-/merge_requests/1557
1 parent 50e8885 commit af71a8e

File tree

2 files changed

+20
-1
lines changed

2 files changed

+20
-1
lines changed

src/wayland/meta-wayland-subsurface.c

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -147,7 +147,8 @@ meta_wayland_subsurface_union_geometry (MetaWaylandSubsurface *subsurface,
147147
.height = meta_wayland_surface_get_height (surface),
148148
};
149149

150-
meta_rectangle_union (out_geometry, &geometry, out_geometry);
150+
if (surface->buffer_ref.buffer)
151+
meta_rectangle_union (out_geometry, &geometry, out_geometry);
151152

152153
META_WAYLAND_SURFACE_FOREACH_SUBSURFACE (surface, subsurface_surface)
153154
{

src/wayland/meta-wayland-xdg-shell.c

Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1506,6 +1506,15 @@ xdg_surface_set_window_geometry (struct wl_client *client,
15061506
MetaWaylandSurface *surface = surface_from_xdg_surface_resource (resource);
15071507
MetaWaylandSurfaceState *pending;
15081508

1509+
if (width == 0 || height == 0)
1510+
{
1511+
g_warning ("Invalid geometry %dx%d+%d+%d set on xdg_surface@%d. Ignoring for "
1512+
"now, but this will result in client termination in the future.",
1513+
width, height, x, y,
1514+
wl_resource_get_id (resource));
1515+
return;
1516+
}
1517+
15091518
pending = meta_wayland_surface_get_pending_state (surface);
15101519
pending->has_new_geometry = TRUE;
15111520
pending->new_geometry.x = x;
@@ -1603,6 +1612,15 @@ meta_wayland_xdg_surface_post_apply_state (MetaWaylandSurfaceRole *surface_role
16031612
meta_wayland_shell_surface_determine_geometry (shell_surface,
16041613
&pending->new_geometry,
16051614
&priv->geometry);
1615+
if (priv->geometry.width == 0 || priv->geometry.height == 0)
1616+
{
1617+
g_warning ("Invalid window geometry for xdg_surface@%d. Ignoring "
1618+
"for now, but this will result in client termination "
1619+
"in the future.",
1620+
wl_resource_get_id (priv->resource));
1621+
return;
1622+
}
1623+
16061624
priv->has_set_geometry = TRUE;
16071625
}
16081626
else if (priv->has_set_geometry)

0 commit comments

Comments
 (0)