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>
This commit is contained in:
Wang Yu 2026-03-03 14:37:42 +08:00
parent 6d9aa17572
commit a55b85e2e1

View file

@ -283,6 +283,8 @@ static bool xwm_selection_send_data(struct wlr_xwm_selection *selection,
int p[2]; int p[2];
if (pipe(p) == -1) { if (pipe(p) == -1) {
wlr_log_errno(WLR_ERROR, "pipe() failed"); wlr_log_errno(WLR_ERROR, "pipe() failed");
wl_array_release(&transfer->source_data);
free(transfer);
return false; return false;
} }