From 3fc416a9b6c9674a3dff65d1745d9ddee2c2547f Mon Sep 17 00:00:00 2001 From: lkn Date: Sat, 6 Jun 2026 17:50:01 +0200 Subject: [PATCH] fixup: wl_monitors_query returns scr->heads directly instead of making a copy (avoids leak) --- src/backend/wayland/wl_screen.c | 15 ++++----------- 1 file changed, 4 insertions(+), 11 deletions(-) diff --git a/src/backend/wayland/wl_screen.c b/src/backend/wayland/wl_screen.c index 63f0014..8e7f2c4 100644 --- a/src/backend/wayland/wl_screen.c +++ b/src/backend/wayland/wl_screen.c @@ -596,19 +596,12 @@ wl_monitors_query(WScreen *scr, WHeadGeometry **heads_out, int *count_out) return; } - /* Rebuild head data from current layout */ + /* Rebuild head data from current layout. + * The caller takes ownership of the returned head array + * (freed on the next call to wl_screen_refresh_heads). */ wl_screen_refresh_heads(scr); - if (scr->head_count == 0 || !scr->heads) { - *heads_out = NULL; - *count_out = 0; - return; - } - - /* Return a copy the caller owns */ - WHeadGeometry *out = wmalloc(sizeof(WHeadGeometry) * scr->head_count); - memcpy(out, scr->heads, sizeof(WHeadGeometry) * scr->head_count); - *heads_out = out; + *heads_out = scr->heads; *count_out = scr->head_count; }