public inbox for linux-nfs@vger.kernel.org
 help / color / mirror / Atom feed
From: Steve Dickson <steved@redhat.com>
To: Libtirpc-devel Mailing List <libtirpc-devel@lists.sourceforge.net>
Cc: Linux NFS Mailing list <linux-nfs@vger.kernel.org>
Subject: Re: [Libtirpc-devel] [PATCH 1/2] rpcb_clnt.c: memory leak in destroy_addr
Date: Mon, 7 Aug 2023 07:15:48 -0400	[thread overview]
Message-ID: <e9bb64cb-eece-f6e7-9a13-e059e2e088ae@redhat.com> (raw)
In-Reply-To: <20230801144209.557175-1-steved@redhat.com>



On 8/1/23 10:42 AM, Steve Dickson wrote:
> From: Herb Wartens <wartens2@llnl.gov>
> 
> Null pointers so they are not used again
> 
> Fixes: https://bugzilla.redhat.com/show_bug.cgi?id=2225226
> Signed-off-by: Steve Dickson <steved@redhat.com>
Committed... (tag: libtirpc-1-3-4-rc2)

steved
> ---
>   src/rpcb_clnt.c | 20 +++++++++++++++-----
>   1 file changed, 15 insertions(+), 5 deletions(-)
> 
> diff --git a/src/rpcb_clnt.c b/src/rpcb_clnt.c
> index d178d86..c0a9e12 100644
> --- a/src/rpcb_clnt.c
> +++ b/src/rpcb_clnt.c
> @@ -104,17 +104,27 @@ destroy_addr(addr)
>   {
>   	if (addr == NULL)
>   		return;
> -	if(addr->ac_host != NULL)
> +	if (addr->ac_host != NULL) {
>   		free(addr->ac_host);
> -	if(addr->ac_netid != NULL)
> +		addr->ac_host = NULL;
> +	}
> +	if (addr->ac_netid != NULL) {
>   		free(addr->ac_netid);
> -	if(addr->ac_uaddr != NULL)
> +		addr->ac_netid = NULL;
> +	}
> +	if (addr->ac_uaddr != NULL) {
>   		free(addr->ac_uaddr);
> -	if(addr->ac_taddr != NULL) {
> -		if(addr->ac_taddr->buf != NULL)
> +		addr->ac_uaddr = NULL;
> +	}
> +	if (addr->ac_taddr != NULL) {
> +		if(addr->ac_taddr->buf != NULL) {
>   			free(addr->ac_taddr->buf);
> +			addr->ac_taddr->buf = NULL;
> +		}
> +		addr->ac_taddr = NULL;
>   	}
>   	free(addr);
> +	addr = NULL;
>   }
>   
>   /*


      parent reply	other threads:[~2023-08-07 11:19 UTC|newest]

Thread overview: 4+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2023-08-01 14:42 [PATCH 1/2] rpcb_clnt.c: memory leak in destroy_addr Steve Dickson
2023-08-01 14:42 ` [PATCH 2/2] rpcb_clnt.c: Eliminate double frees in delete_cache() Steve Dickson
2023-08-07 11:16   ` [Libtirpc-devel] " Steve Dickson
2023-08-07 11:15 ` Steve Dickson [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=e9bb64cb-eece-f6e7-9a13-e059e2e088ae@redhat.com \
    --to=steved@redhat.com \
    --cc=libtirpc-devel@lists.sourceforge.net \
    --cc=linux-nfs@vger.kernel.org \
    /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