From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from us-smtp-delivery-124.mimecast.com (us-smtp-delivery-124.mimecast.com [170.10.129.124]) by sourceware.org (Postfix) with ESMTPS id 16FDF3857815 for ; Thu, 21 Oct 2021 19:34:13 +0000 (GMT) DMARC-Filter: OpenDMARC Filter v1.4.1 sourceware.org 16FDF3857815 Received: from mail-qv1-f70.google.com (mail-qv1-f70.google.com [209.85.219.70]) (Using TLS) by relay.mimecast.com with ESMTP id us-mta-125-c4sTb5W2Mxenme0M8E9R_g-1; Thu, 21 Oct 2021 15:34:09 -0400 X-MC-Unique: c4sTb5W2Mxenme0M8E9R_g-1 Received: by mail-qv1-f70.google.com with SMTP id el19-20020ad459d3000000b00384a5ef8979so1874339qvb.18 for ; Thu, 21 Oct 2021 12:34:09 -0700 (PDT) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=x-gm-message-state:message-id:date:mime-version:user-agent:subject :content-language:to:references:from:in-reply-to :content-transfer-encoding; bh=R/1EeULasJ6EPR9QWM8Osfi3837b+3/Q6P7Xccm+LR0=; b=pOg4XPBko8EXTrASYCLYP0dsLEj2+Qzk+kqfI2V+hGys4PEBZygl4IpKBYqJpYH0L6 gAE0j9sjYYNuhR4nSP6RfSd/pEhwg54CMXcYJ2GQb8nI/JNm5gDfQJIbLDf9qZYgniBP gA8wexNNaxtFMCHg4mL2YxQdITVblzdGQezqZQpDO4dfXWW7VV5ObudBteXahr5YG4Xz 7qLGCaPjYQs53lNLc0Mastur1+TxZfwgABbENSKcsiSnMCRyZcciF/ZT6jkLjHoQdtm3 Vc/vTD8VHoaB+kcvM24+oZkMXUeTx3gG/rb5wd+Y0jsiqWhzZ7rjS5dzPtuAkZV+skUQ IL9w== X-Gm-Message-State: AOAM531CrY9ccd4DEx2bwJMkfq951k5BN6kg7eMuxa5ODSQjXEEuf5M7 hRmajanh9M3lBXcdOMqQtavhwxd93VvVX0Y6i4iJRngDWFKdsaCLzyIwAdk0byQRdjp3AAE2XSV qLoc8L0O1RGiluM23CQ== X-Received: by 2002:ac8:7d47:: with SMTP id h7mr8032341qtb.92.1634844848657; Thu, 21 Oct 2021 12:34:08 -0700 (PDT) X-Google-Smtp-Source: ABdhPJzQgV85JmXmBnX5DkCkXtbGy6vRPsCLUn9HZRV6SPLSJAfGAMuNkrM/w5j8E7koICHJ7QXz0Q== X-Received: by 2002:ac8:7d47:: with SMTP id h7mr8032309qtb.92.1634844848334; Thu, 21 Oct 2021 12:34:08 -0700 (PDT) Received: from [192.168.1.149] (130-44-159-43.s15913.c3-0.arl-cbr1.sbo-arl.ma.cable.rcncustomer.com. [130.44.159.43]) by smtp.gmail.com with ESMTPSA id o16sm2508576qkp.1.2021.10.21.12.34.07 (version=TLS1_3 cipher=TLS_AES_128_GCM_SHA256 bits=128/128); Thu, 21 Oct 2021 12:34:07 -0700 (PDT) Message-ID: Date: Thu, 21 Oct 2021 15:34:06 -0400 MIME-Version: 1.0 User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:91.0) Gecko/20100101 Thunderbird/91.2.0 Subject: Re: [PATCH] libcody: Avoid double-free To: Jonathan Wakely , gcc-patches@gcc.gnu.org References: <20211021132714.636039-1-jwakely@redhat.com> From: Jason Merrill In-Reply-To: <20211021132714.636039-1-jwakely@redhat.com> X-Mimecast-Spam-Score: 0 X-Mimecast-Originator: redhat.com Content-Language: en-US Content-Type: text/plain; charset=UTF-8; format=flowed Content-Transfer-Encoding: 7bit X-Spam-Status: No, score=-14.2 required=5.0 tests=BAYES_00, DKIMWL_WL_HIGH, DKIM_SIGNED, DKIM_VALID, DKIM_VALID_AU, DKIM_VALID_EF, GIT_PATCH_0, NICE_REPLY_A, RCVD_IN_DNSWL_LOW, RCVD_IN_MSPIKE_H4, RCVD_IN_MSPIKE_WL, SPF_HELO_NONE, SPF_NONE, TXREP autolearn=ham autolearn_force=no version=3.4.4 X-Spam-Checker-Version: SpamAssassin 3.4.4 (2020-01-24) on server2.sourceware.org X-BeenThere: gcc-patches@gcc.gnu.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: Gcc-patches mailing list List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Thu, 21 Oct 2021 19:34:15 -0000 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) > { >