unofficial mirror of bug-gnu-emacs@gnu.org 
 help / color / mirror / code / Atom feed
From: Noam Postavsky <npostavs@gmail.com>
To: YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
Cc: 32604@debbugs.gnu.org
Subject: bug#32604: 26.1.50; memory leak in connect_network_socket
Date: Sun, 02 Sep 2018 13:55:46 -0400	[thread overview]
Message-ID: <87k1o3rdgd.fsf@gmail.com> (raw)
In-Reply-To: <B2134A53-7492-4861-8725-871C8521594A@math.s.chiba-u.ac.jp> (YAMAMOTO Mitsuharu's message of "Sat, 1 Sep 2018 14:38:51 +0900")

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);





  parent reply	other threads:[~2018-09-02 17:55 UTC|newest]

Thread overview: 8+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2018-09-01  5:38 bug#32604: 26.1.50; memory leak in connect_network_socket YAMAMOTO Mitsuharu
2018-09-01  5:46 ` YAMAMOTO Mitsuharu
2018-09-02 17:55 ` Noam Postavsky [this message]
2018-09-03  6:02   ` mituharu
2018-09-04 23:19     ` Noam Postavsky
2018-09-05 23:50       ` YAMAMOTO Mitsuharu
2018-09-06  0:04         ` Noam Postavsky
2018-09-06 23:41           ` YAMAMOTO Mitsuharu

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

  List information: https://www.gnu.org/software/emacs/

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=87k1o3rdgd.fsf@gmail.com \
    --to=npostavs@gmail.com \
    --cc=32604@debbugs.gnu.org \
    --cc=mituharu@math.s.chiba-u.ac.jp \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
Code repositories for project(s) associated with this public inbox

	https://git.savannah.gnu.org/cgit/emacs.git

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).