eis: fix two file descriptor leaks on error

Assisted-by: Claude:claude-opus-4-6
Part-of: <https://gitlab.freedesktop.org/libinput/libei/-/merge_requests/388>
This commit is contained in:
Peter Hutterer 2026-04-18 09:12:11 +10:00 committed by Marge Bot
parent 62ac026432
commit c436bd37ec
2 changed files with 9 additions and 1 deletions

View file

@ -28,6 +28,7 @@
#include <sys/socket.h>
#include <sys/un.h>
#include "util-io.h"
#include "util-macros.h"
#include "util-mem.h"
#include "util-sources.h"
@ -83,8 +84,11 @@ eis_backend_fd_add_client(struct eis *eis)
return -errno;
struct eis_client *client = eis_client_new(eis, fds[0]);
if (client == NULL)
if (client == NULL) {
xclose(fds[0]);
xclose(fds[1]);
return -ENOMEM;
}
eis_client_unref(client);

View file

@ -115,6 +115,10 @@ listener_dispatch(struct source *source, void *data)
return;
struct eis_client *client = eis_client_new(eis, fd);
if (client == NULL) {
xclose(fd);
return;
}
eis_client_unref(client);
}