Reported by Frediano Ziglio. if udscs_create_server_for_fd() fails, it will return NULL and the file descriptor will be leaked. Since the calling function is the one that created the fd, it should free the fd if the server could not be created. Signed-off-by: Jonathon Jongsma <jjongsma@xxxxxxxxxx> --- src/udscs.c | 13 ++++++++++--- 1 file changed, 10 insertions(+), 3 deletions(-) diff --git a/src/udscs.c b/src/udscs.c index 6e73015..c439f23 100644 --- a/src/udscs.c +++ b/src/udscs.c @@ -438,6 +438,7 @@ struct udscs_server *udscs_create_server(const char *socketname, int c; int fd; struct sockaddr_un address; + struct udscs_server *server; fd = socket(PF_UNIX, SOCK_STREAM, 0); if (fd == -1) { @@ -461,9 +462,15 @@ struct udscs_server *udscs_create_server(const char *socketname, return NULL; } - return udscs_create_server_for_fd(fd, connect_callback, read_callback, - disconnect_callback, type_to_string, - no_types, debug); + server = udscs_create_server_for_fd(fd, connect_callback, read_callback, + disconnect_callback, type_to_string, + no_types, debug); + + if (!server) { + close(fd); + } + + return server; } void udscs_destroy_server(struct udscs_server *server) -- 2.13.6 _______________________________________________ Spice-devel mailing list Spice-devel@xxxxxxxxxxxxxxxxxxxxx https://lists.freedesktop.org/mailman/listinfo/spice-devel