From: Paul Eggert Date: Thu, 21 Jul 2016 09:27:55 +0000 (+0200) Subject: Fix use-after-close in connect_network_socket X-Git-Tag: emacs-26.0.90~1840^2~28 X-Git-Url: http://git.eshelyaron.com/gitweb/?a=commitdiff_plain;h=a066fb1ceee373c982214c28206108c5fba01bf7;p=emacs.git Fix use-after-close in connect_network_socket * src/process.c (connect_network_socket): Don’t use external_sock_fd after closing it. Problem found by Coverity Scan. --- diff --git a/src/process.c b/src/process.c index bdbdefabb64..bc2ac451c9d 100644 --- a/src/process.c +++ b/src/process.c @@ -3185,6 +3185,8 @@ connect_network_socket (Lisp_Object proc, Lisp_Object addrinfos, xerrno = errno; emacs_close (s); s = -1; + if (socket_to_use < 0) + break; continue; } } @@ -3312,6 +3314,8 @@ connect_network_socket (Lisp_Object proc, Lisp_Object addrinfos, specpdl_ptr = specpdl + count1; emacs_close (s); s = -1; + if (socket_to_use < 0) + break; #ifdef WINDOWSNT if (xerrno == EINTR)