From a55b85e2e1138f9534890e4dc6a224ec2efb9d4d Mon Sep 17 00:00:00 2001 From: Wang Yu Date: Tue, 3 Mar 2026 14:37:42 +0800 Subject: [PATCH] xwayland: fix memory leak on pipe() failure When pipe() fails in xwm_selection_send_data(), the function returns without cleaning up the allocated transfer structure and initialized wl_array. This causes a memory leak. Add wl_array_release() and free() to clean up resources when pipe() fails. Signed-off-by: Wang Yu --- xwayland/selection/outgoing.c | 2 ++ 1 file changed, 2 insertions(+) diff --git a/xwayland/selection/outgoing.c b/xwayland/selection/outgoing.c index 795a4768b..6216abbb4 100644 --- a/xwayland/selection/outgoing.c +++ b/xwayland/selection/outgoing.c @@ -283,6 +283,8 @@ static bool xwm_selection_send_data(struct wlr_xwm_selection *selection, int p[2]; if (pipe(p) == -1) { wlr_log_errno(WLR_ERROR, "pipe() failed"); + wl_array_release(&transfer->source_data); + free(transfer); return false; }