aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorKenny Levinsen <kl@kl.wtf>2024-02-22 13:44:46 +0100
committerKenny Levinsen <kl@kl.wtf>2024-02-22 14:10:46 +0100
commit837060f894a4aba7d069b35f4600003fb0d10036 (patch)
tree539faecf22bcdc7834261f6a949c28e91a031619
parent0cb091f1a2d345f37d2ee445f4ffd04f7f4ec9e5 (diff)
xwayland/xwm: Avoid zero-size allocaiton
Zero-sized allocations have glibc-specific behavior, so avoid those.
-rw-r--r--xwayland/xwm.c19
1 files changed, 11 insertions, 8 deletions
diff --git a/xwayland/xwm.c b/xwayland/xwm.c
index c75f2be7..8cc64a12 100644
--- a/xwayland/xwm.c
+++ b/xwayland/xwm.c
@@ -290,15 +290,18 @@ static void xwm_set_net_client_list(struct wlr_xwm *xwm) {
}
}
- xcb_window_t *windows = malloc(sizeof(xcb_window_t) * mapped_surfaces);
- if (!windows) {
- return;
- }
+ xcb_window_t *windows = NULL;
+ if (mapped_surfaces > 0) {
+ xcb_window_t *windows = malloc(sizeof(*windows) * mapped_surfaces);
+ if (!windows) {
+ return;
+ }
- size_t index = 0;
- wl_list_for_each(surface, &xwm->surfaces, link) {
- if (surface->surface != NULL && surface->surface->mapped) {
- windows[index++] = surface->window_id;
+ size_t index = 0;
+ wl_list_for_each(surface, &xwm->surfaces, link) {
+ if (surface->surface != NULL && surface->surface->mapped) {
+ windows[index++] = surface->window_id;
+ }
}
}