From c83768c76cc79b7428f84ca87e686f3e47ae7093 Mon Sep 17 00:00:00 2001 From: Mike Blumenkrantz Date: Thu, 22 Feb 2024 15:19:18 -0500 Subject: [PATCH] egl/wayland/sw: clamp putimage geometry to surface size this otherwise writes oob Acked-by: Daniel Stone Part-of: --- src/egl/drivers/dri2/platform_wayland.c | 3 +++ 1 file changed, 3 insertions(+) diff --git a/src/egl/drivers/dri2/platform_wayland.c b/src/egl/drivers/dri2/platform_wayland.c index 9db64229d98..f038ae33c84 100644 --- a/src/egl/drivers/dri2/platform_wayland.c +++ b/src/egl/drivers/dri2/platform_wayland.c @@ -2463,6 +2463,9 @@ dri2_wl_swrast_put_image2(__DRIdrawable *draw, int op, int x, int y, int w, int h, int stride, char *data, void *loaderPrivate) { struct dri2_egl_surface *dri2_surf = loaderPrivate; + /* clamp to surface size */ + w = MIN2(w, dri2_surf->base.Width); + h = MIN2(h, dri2_surf->base.Height); int copy_width = dri2_wl_swrast_get_stride_for_format(dri2_surf->format, w); int dst_stride = dri2_wl_swrast_get_stride_for_format(dri2_surf->format, dri2_surf->base.Width);