From patchwork Thu Mar 7 09:52:22 2013 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit Subject: iputils: fix memory leaks From: jb X-Patchwork-Id: 225786 Message-Id: To: netdev@vger.kernel.org Date: Thu, 7 Mar 2013 09:52:22 +0000 (UTC) Fix memory leaks Signed-off-by: JB --- ping.c | 9 +++++++++ 1 file changed, 9 insertions(+) -- To unsubscribe from this list: send the line "unsubscribe netdev" in the body of a message to majordomo@vger.kernel.org More majordomo info at http://vger.kernel.org/majordomo-info.html 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;