mirror of
https://gitlab.freedesktop.org/libinput/libei.git
synced 2026-05-14 20:28:08 +02:00
util: fix possible fd leak if xconnect fails on connect()
Assisted-by: Claude:claude-opus-4-6 Part-of: <https://gitlab.freedesktop.org/libinput/libei/-/merge_requests/388>
This commit is contained in:
parent
1efc6d03d1
commit
f12fe4ce14
1 changed files with 3 additions and 2 deletions
|
|
@ -223,7 +223,8 @@ xconnect(const char *path)
|
|||
if (!xsnprintf(addr.sun_path, sizeof(addr.sun_path), "%s", path))
|
||||
return -EINVAL;
|
||||
|
||||
int sockfd = xerrno(SYSCALL(socket(AF_UNIX, SOCK_STREAM | SOCK_NONBLOCK, 0)));
|
||||
_cleanup_close_ int sockfd =
|
||||
xerrno(SYSCALL(socket(AF_UNIX, SOCK_STREAM | SOCK_NONBLOCK, 0)));
|
||||
if (sockfd < 0)
|
||||
return sockfd;
|
||||
|
||||
|
|
@ -231,7 +232,7 @@ xconnect(const char *path)
|
|||
if (rc < 0)
|
||||
return rc;
|
||||
|
||||
return sockfd;
|
||||
return steal_fd(&sockfd);
|
||||
}
|
||||
|
||||
/**
|
||||
|
|
|
|||
Loading…
Add table
Reference in a new issue