From: Yongcheng Yang <yoyang@redhat.com>
To: Steve Dickson <steved@redhat.com>
Cc: Linux NFS Mailing list <linux-nfs@vger.kernel.org>,
Herb Wartens <wartens2@llnl.gov>,
Yongcheng Yang <yoyang@redhat.com>
Subject: [PATCH 2/2] rpcb_clnt.c: fix memory leak in destroy_addr
Date: Tue, 1 Aug 2023 17:33:10 +0800 [thread overview]
Message-ID: <20230801093310.594942-3-yoyang@redhat.com> (raw)
In-Reply-To: <20230801093310.594942-1-yoyang@redhat.com>
Signed-off-by: Herb Wartens <wartens2@llnl.gov>
---
src/rpcb_clnt.c | 22 +++++++++++++++++-----
1 file changed, 17 insertions(+), 5 deletions(-)
diff --git a/src/rpcb_clnt.c b/src/rpcb_clnt.c
index 630f9ad..539b521 100644
--- a/src/rpcb_clnt.c
+++ b/src/rpcb_clnt.c
@@ -102,19 +102,31 @@ static void
destroy_addr(addr)
struct address_cache *addr;
{
- if (addr == NULL)
+ 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);
+ addr->ac_uaddr = NULL;
+ }
if(addr->ac_taddr != NULL) {
- if(addr->ac_taddr->buf != NULL)
+ if(addr->ac_taddr->buf != NULL) {
free(addr->ac_taddr->buf);
+ addr->ac_taddr->buf = NULL;
+ }
+ free(addr->ac_taddr);
+ addr->ac_taddr = NULL;
}
free(addr);
+ addr = NULL;
}
/*
--
2.31.1
next prev parent reply other threads:[~2023-08-01 9:36 UTC|newest]
Thread overview: 4+ messages / expand[flat|nested] mbox.gz Atom feed top
2023-08-01 9:33 [PATCH 0/2] Double-Free and Memory Leak Found In libtirpc Yongcheng Yang
2023-08-01 9:33 ` [PATCH 1/2] rpcb_clnt.c: fix a possible double free Yongcheng Yang
2023-08-01 9:33 ` Yongcheng Yang [this message]
2024-03-15 20:21 ` [PATCH 2/2] rpcb_clnt.c: fix memory leak in destroy_addr Wartens, Herb
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=20230801093310.594942-3-yoyang@redhat.com \
--to=yoyang@redhat.com \
--cc=linux-nfs@vger.kernel.org \
--cc=steved@redhat.com \
--cc=wartens2@llnl.gov \
/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