Subject: bug#32604: 26.1.50; memory leak in connect_network_socket

From: Noam Postavsky <[email-masked]>
Date: Tue, 04 Sep 2018 19:19:48 -0400

Looks good to me; a couple of minor suggestions below.

[email-masked] writes:

> @@ -3322,6 +3322,7 @@ connect_network_socket (Lisp_Object proc,
> Lisp_Object addrinfos,
>                          Lisp_Object use_external_socket_p)
>  {
>    ptrdiff_t count = SPECPDL_INDEX ();
> +  ptrdiff_t count1 UNINIT;
>    int s = -1, outch, inch;
>    int xerrno = 0;
>    int family;
> @@ -3344,6 +3345,9 @@ connect_network_socket (Lisp_Object proc,
> Lisp_Object addrinfos,
>    /* Do this in case we never enter the while-loop below.  */
>    s = -1;
>
> +  record_unwind_protect_nothing ();
> +  count1 = SPECPDL_INDEX ();

Since we assume a C99 compiler now, you could just do

    ptrdiff_t count1 = SPECPDL_INDEX ();

without having the UNINIT thing.  Also, since free is harmless on a NULL
pointer, you could just record an unwind protect at the top once,
without having the nothing state, I think.