diff --git a/compositor/main.c b/compositor/main.c index 21111013..27be96a3 100644 --- a/compositor/main.c +++ b/compositor/main.c @@ -396,7 +396,7 @@ weston_client_launch(struct weston_compositor *compositor, { struct wl_client *client = NULL; struct custom_env child_env; - struct fdstr wayland_socket; + struct fdstr wayland_socket = FDSTR_INIT; const char *fail_cloexec = "Couldn't unset CLOEXEC on client socket"; const char *fail_seteuid = "Couldn't call seteuid"; char *fail_exec; diff --git a/compositor/xwayland.c b/compositor/xwayland.c index ea1ae1ef..322a9782 100644 --- a/compositor/xwayland.c +++ b/compositor/xwayland.c @@ -96,11 +96,11 @@ spawn_xserver(void *user_data, const char *display, int abstract_fd, int unix_fd { struct wet_xwayland *wxw = user_data; pid_t pid; - struct fdstr wayland_socket; - struct fdstr x11_abstract_socket; - struct fdstr x11_unix_socket; - struct fdstr x11_wm_socket; - struct fdstr display_pipe; + struct fdstr wayland_socket = FDSTR_INIT; + struct fdstr x11_abstract_socket = FDSTR_INIT; + struct fdstr x11_unix_socket = FDSTR_INIT; + struct fdstr x11_wm_socket = FDSTR_INIT; + struct fdstr display_pipe = FDSTR_INIT; char *xserver = NULL; struct weston_config *config = wet_get_config(wxw->compositor); struct weston_config_section *section; diff --git a/shared/process-util.c b/shared/process-util.c index e36c6470..fe895d23 100644 --- a/shared/process-util.c +++ b/shared/process-util.c @@ -68,7 +68,8 @@ fdstr_close_all(struct fdstr *s) unsigned i; for (i = 0; i < ARRAY_LENGTH(s->fds); i++) { - close(s->fds[i]); + if (s->fds[i] >= 0) + close(s->fds[i]); s->fds[i] = -1; } } diff --git a/shared/process-util.h b/shared/process-util.h index 05543f6f..aa35c776 100644 --- a/shared/process-util.h +++ b/shared/process-util.h @@ -59,6 +59,7 @@ fdstr_clear_cloexec_fd1(struct fdstr *s); void fdstr_close_all(struct fdstr *s); +#define FDSTR_INIT ((struct fdstr){ { 0 }, { -1, -1 }}) /** * A container for environment variables and/or process arguments, designed to