mirror of
https://github.com/hyprwm/wlroots-hyprland.git
synced 2024-12-22 18:09:49 +01:00
render/dmabuf: cleanup on wlr_dmabuf_attributes_copy error
This commit is contained in:
parent
975d14b799
commit
7ac2ce25e3
1 changed files with 11 additions and 2 deletions
|
@ -16,13 +16,22 @@ bool wlr_dmabuf_attributes_copy(struct wlr_dmabuf_attributes *dst,
|
|||
struct wlr_dmabuf_attributes *src) {
|
||||
memcpy(dst, src, sizeof(struct wlr_dmabuf_attributes));
|
||||
|
||||
for (int i = 0; i < src->n_planes; ++i) {
|
||||
int i;
|
||||
for (i = 0; i < src->n_planes; ++i) {
|
||||
dst->fd[i] = fcntl(src->fd[i], F_DUPFD_CLOEXEC, 0);
|
||||
if (dst->fd[i] < 0) {
|
||||
wlr_log_errno(WLR_ERROR, "fcntl(F_DUPFD_CLOEXEC) failed");
|
||||
return false;
|
||||
goto error;
|
||||
}
|
||||
}
|
||||
|
||||
return true;
|
||||
|
||||
error:
|
||||
for (int j = 0; j < i; j++) {
|
||||
close(dst->fd[i]);
|
||||
dst->fd[j] = -1;
|
||||
}
|
||||
dst->n_planes = 0;
|
||||
return false;
|
||||
}
|
||||
|
|
Loading…
Reference in a new issue