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 <wangyu@uniontech.com>
(cherry picked from commit a55b85e2e1)
This commit is contained in:
Wang Yu 2026-03-03 14:37:42 +08:00 committed by Simon Zeni
parent 0f9a1f1443
commit d834de6167

View file

@ -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;
}