提交 bd5d2353 编写于 作者: P Peter Maydell 提交者: Samuel Thibault

slirp: tcp_listen(): Don't try to close() an fd we never opened

Coverity points out (CID 1005725) that an error-exit path in tcp_listen()
will try to close(s) even if the reason it got there was that the
qemu_socket() failed and s was never opened.  Not only that, this isn't even
the right function to use, because we need closesocket() to do the right
thing on Windows.  Change to using the right function and only calling it if
needed.
Signed-off-by: NPeter Maydell <peter.maydell@linaro.org>
Reviewed-by: NPhilippe Mathieu-Daudé <f4bug@amsat.org>
Signed-off-by: NSamuel Thibault <samuel.thibault@ens-lyon.org>
上级 70f2e64e
...@@ -713,7 +713,9 @@ tcp_listen(Slirp *slirp, uint32_t haddr, u_int hport, uint32_t laddr, ...@@ -713,7 +713,9 @@ tcp_listen(Slirp *slirp, uint32_t haddr, u_int hport, uint32_t laddr,
(listen(s,1) < 0)) { (listen(s,1) < 0)) {
int tmperrno = errno; /* Don't clobber the real reason we failed */ int tmperrno = errno; /* Don't clobber the real reason we failed */
close(s); if (s >= 0) {
closesocket(s);
}
sofree(so); sofree(so);
/* Restore the real errno */ /* Restore the real errno */
#ifdef _WIN32 #ifdef _WIN32
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册