From d5a885882bc31803c7a84417a9dfa79632fec7b6 Mon Sep 17 00:00:00 2001 From: Toomas Rosin Date: Wed, 9 Sep 2026 13:29:48 +0100 Subject: [PATCH] x_get_net_workarea: Fix indexing of _NET_WORKAREA (bug#81761) * src/xfns.c (x_get_net_workarea): Fix indexing of _NET_WORKAREA (bug#81761). Copyright-paperwork-exempt: yes --- src/xfns.c | 15 +++++++++------ 1 file changed, 9 insertions(+), 6 deletions(-) diff --git a/src/xfns.c b/src/xfns.c index fdb8eaf7f84..7b79ae54f7f 100644 --- a/src/xfns.c +++ b/src/xfns.c @@ -6097,16 +6097,19 @@ x_get_net_workarea (struct x_display_info *dpyinfo, XRectangle *rect) free (error), rc = false; else { + size_t value_count = xcb_get_property_value_length (reply) + / sizeof (uint32_t); + if (rc && reply->type == XA_CARDINAL && reply->format == 32 - && (xcb_get_property_value_length (reply) / sizeof (uint32_t) - >= current_workspace + 4)) + && current_workspace < value_count / 4) { + size_t offset = 4 * (size_t) current_workspace; values = xcb_get_property_value (reply); - rect->x = values[current_workspace]; - rect->y = values[current_workspace + 1]; - rect->width = values[current_workspace + 2]; - rect->height = values[current_workspace + 3]; + rect->x = values[offset]; + rect->y = values[offset + 1]; + rect->width = values[offset + 2]; + rect->height = values[offset + 3]; } else rc = false;