From 63df2bcbe656b394b0bd152ab69147194dd74815 Mon Sep 17 00:00:00 2001 From: Simon Ser Date: Fri, 6 Nov 2020 09:57:03 +0100 Subject: backend/session: don't return FD on failure in open_file When wlr_session_open_file fails, don't return the FD, otherwise the caller will think the call succeeded. --- backend/session/session.c | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/backend/session/session.c b/backend/session/session.c index d8e9509d..e3e108af 100644 --- a/backend/session/session.c +++ b/backend/session/session.c @@ -6,6 +6,7 @@ #include #include #include +#include #include #include #include @@ -195,7 +196,8 @@ int wlr_session_open_file(struct wlr_session *session, const char *path) { error: free(dev); - return fd; + close(fd); + return -1; } static struct wlr_device *find_device(struct wlr_session *session, int fd) { -- cgit v1.2.3