diff --git a/.pick_status.json b/.pick_status.json index 168032fa74a..6e326aa505b 100644 --- a/.pick_status.json +++ b/.pick_status.json @@ -1822,7 +1822,7 @@ "description": "util: fix possible fd leaks in os_socket_listen_abstract", "nominated": true, "nomination_type": 1, - "resolution": 0, + "resolution": 1, "master_sha": null, "because_sha": "ef5266ebd50e7fa65c56bdb623e12ca8c233b470" }, diff --git a/src/util/os_socket.c b/src/util/os_socket.c index 98ef013205e..6562cccaddd 100644 --- a/src/util/os_socket.c +++ b/src/util/os_socket.c @@ -33,10 +33,15 @@ os_socket_listen_abstract(const char *path, int count) int ret = bind(s, (struct sockaddr*)&addr, offsetof(struct sockaddr_un, sun_path) + strlen(path) + 1); - if (ret < 0) + if (ret < 0) { + close(s); return -1; + } - listen(s, count); + if (listen(s, count) < 0) { + close(s); + return -1; + } return s; }