bug-gnu-emacs
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

bug#32604: 26.1.50; memory leak in connect_network_socket


From: Noam Postavsky
Subject: bug#32604: 26.1.50; memory leak in connect_network_socket
Date: Sun, 02 Sep 2018 13:55:46 -0400
User-agent: Gnus/5.13 (Gnus v5.13) Emacs/26.1 (gnu/linux)

YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp> writes:

> In connect_network_socket (in process.c), the memory pointed to
> by the variable `sa’ doesn’t seem to be deallocated.
>
>   3328          struct sockaddr *sa = NULL;
>       :
>   3347          while (!NILP (addrinfos))
>   3348            {
>       :
>   3359              if (sa)
>   3360                free (sa);
>   3361              sa = xmalloc (addrlen);
>       :
>   3533            }
>       :
>
> The following patch would fix the leak:

> +  xfree (sa);

I think we would need

    record_unwind_protect_ptr (xfree, sa);

to handle the case where an error is signaled.  Similar to how the
socket closing is handled:

      /* Make us close S if quit.  */
      record_unwind_protect_int (close_file_unwind, s);





reply via email to

[Prev in Thread] Current Thread [Next in Thread]