From: jb <jb.1234abcd@gmail.com>
To: netdev@vger.kernel.org
Subject: [PATCH] iputils: fix memory leaks
Date: Thu, 7 Mar 2013 09:52:22 +0000 (UTC) [thread overview]
Message-ID: <loom.20130307T103516-549@post.gmane.org> (raw)
Fix memory leaks
Signed-off-by: JB <jb.1234abcd@gmail.com>
---
ping.c | 9 +++++++++
1 file changed, 9 insertions(+)
diff --git a/ping.c b/ping.c
index c0366cd..04f5596 100644
--- a/ping.c
+++ b/ping.c
@@ -282,10 +282,15 @@ main(int argc, char **argv)
hp = gethostbyname(idn);
if (!hp) {
fprintf(stderr, "ping: unknown host %s\n", target);
+#ifdef USE_IDN
+ free(idn);
+ idn = NULL;
+#endif
exit(2);
}
#ifdef USE_IDN
free(idn);
+ idn = NULL;
#endif
memcpy(&whereto.sin_addr, hp->h_addr, 4);
#ifdef USE_IDN
@@ -301,6 +306,10 @@ main(int argc, char **argv)
hnamebuf[sizeof(hnamebuf) - 1] = 0;
#endif
hostname = hnamebuf;
+#ifdef USE_IDN
+ free(hnamebuf);
+ hnamebuf = NULL;
+#endif
}
if (argc > 1)
route[nroute++] = whereto.sin_addr.s_addr;
next reply other threads:[~2013-03-07 9:54 UTC|newest]
Thread overview: 3+ messages / expand[flat|nested] mbox.gz Atom feed top
2013-03-07 9:52 jb [this message]
2013-03-07 10:06 ` [PATCH] iputils: fix memory leaks David Laight
2013-03-07 11:18 ` jb
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=loom.20130307T103516-549@post.gmane.org \
--to=jb.1234abcd@gmail.com \
--cc=netdev@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