public inbox for gcc-patches@gcc.gnu.org
 help / color / mirror / Atom feed
From: Jason Merrill <jason@redhat.com>
To: Jonathan Wakely <jwakely@redhat.com>, gcc-patches@gcc.gnu.org
Subject: Re: [PATCH] libcody: Avoid double-free
Date: Thu, 21 Oct 2021 15:34:06 -0400	[thread overview]
Message-ID: <b66941b2-a6c0-902d-0c63-91c9bb3ce44e@redhat.com> (raw)
In-Reply-To: <20211021132714.636039-1-jwakely@redhat.com>

On 10/21/21 09:27, Jonathan Wakely wrote:
> If the listen call fails then 'goto fail' will jump to that label and
> use freeaddrinfo again. Set the pointer to null to prevent that.

OK.

> libcody/ChangeLog:
> 
> 	* netserver.cc (ListenInet6): Set pointer to null after
> 	deallocation.
> ---
>   libcody/netserver.cc | 1 +
>   1 file changed, 1 insertion(+)
> 
> diff --git a/libcody/netserver.cc b/libcody/netserver.cc
> index 30202c5106a..0499b5790b4 100644
> --- a/libcody/netserver.cc
> +++ b/libcody/netserver.cc
> @@ -140,6 +140,7 @@ int ListenInet6 (char const **e, char const *name, int port, unsigned backlog)
>   
>    listen:;
>     freeaddrinfo (addrs);
> +  addrs = nullptr;
>   
>     if (listen (fd, backlog ? backlog : 17) < 0)
>       {
> 


      parent reply	other threads:[~2021-10-21 19:34 UTC|newest]

Thread overview: 3+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2021-10-21 13:27 Jonathan Wakely
2021-10-21 13:30 ` Jonathan Wakely
2021-10-21 19:34 ` Jason Merrill [this message]

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

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

  git send-email \
    --in-reply-to=b66941b2-a6c0-902d-0c63-91c9bb3ce44e@redhat.com \
    --to=jason@redhat.com \
    --cc=gcc-patches@gcc.gnu.org \
    --cc=jwakely@redhat.com \
    /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.
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).