Patchwork [2/2] ping: Don't free an unintialized value.

login
register
mail settings
Submitter Jan Synacek
Date Nov. 14, 2012, 12:57 p.m.
Message ID <1352897836-17603-3-git-send-email-jsynacek@redhat.com>
Download mbox | patch
Permalink /patch/198893/
State Not Applicable
Delegated to: David Miller
Headers show

Comments

Jan Synacek - Nov. 14, 2012, 12:57 p.m.
---
 ping.c | 8 +++++---
 1 file changed, 5 insertions(+), 3 deletions(-)

Patch

diff --git a/ping.c b/ping.c
index fe9ff8a..9de3d08 100644
--- a/ping.c
+++ b/ping.c
@@ -122,7 +122,7 @@  main(int argc, char **argv)
 	u_char *packet;
 	char *target;
 #ifdef USE_IDN
-	char *hnamebuf;
+	char *hnamebuf = NULL;
 #else
 	char hnamebuf[MAX_HOSTNAMELEN];
 #endif
@@ -263,8 +263,10 @@  main(int argc, char **argv)
 #ifdef USE_IDN
 			int rc;
 
-			free(hnamebuf);
-			hnamebuf = NULL;
+			if (hnamebuf) {
+				free(hnamebuf);
+				hnamebuf = NULL;
+			}
 
 			rc = idna_to_ascii_lz(target, &idn, 0);
 			if (rc != IDNA_SUCCESS) {