plugins: Fix resource leak in connect_socket()

Close the fd when the connect() fails.

Reported-by: Euler Robot <euler.robot@huawei.com>
Signed-off-by: Alex Chen <alex.chen@huawei.com>
Signed-off-by: Alex Bennée <alex.bennee@linaro.org>
Message-Id: <20201109082829.87496-2-alex.chen@huawei.com>
Message-Id: <20201110192316.26397-2-alex.bennee@linaro.org>
This commit is contained in:
Alex Chen 2020-11-10 19:23:07 +00:00 committed by Alex Bennée
parent b50ea0d54b
commit dbb864ba4f

View file

@ -292,6 +292,7 @@ static bool connect_socket(const char *path)
if (connect(fd, (struct sockaddr *)&sockaddr, sizeof(sockaddr)) < 0) {
perror("failed to connect");
close(fd);
return false;
}