changeset 12565:3f895385e841

[gaim-migrate @ 14884] Don't assume that gethostbyname() was successful. This should fix #1384291. committer: Tailor Script <tailor@pidgin.im>
author Daniel Atallah <daniel.atallah@gmail.com>
date Mon, 19 Dec 2005 17:16:15 +0000
parents 01e18ead06a0
children fd6ffacbb6ee
files src/protocols/simple/simple.c
diffstat 1 files changed, 6 insertions(+), 1 deletions(-) [+]
line wrap: on
line diff
--- a/src/protocols/simple/simple.c	Mon Dec 19 17:06:59 2005 +0000
+++ b/src/protocols/simple/simple.c	Mon Dec 19 17:16:15 2005 +0000
@@ -1239,6 +1239,12 @@
 
 	} else { /* UDP */
 		gaim_debug_info("simple", "using udp with server %s and port %d\n", hostname, port);
+
+		/** TODO: this should probably be async, right? */
+		if (!(h = gethostbyname(hostname))) {
+			gaim_connection_error(sip->gc, _("Couldn't resolve host"));
+		}
+
 		sip->fd = socket(AF_INET, SOCK_DGRAM, 0);
 
 		addr.sin_family = AF_INET;
@@ -1254,7 +1260,6 @@
 		sip->serveraddr.sin_family = AF_INET;
 		sip->serveraddr.sin_port = htons(port);
 
-		h = gethostbyname(hostname);
 		sip->serveraddr.sin_addr.s_addr = ((struct in_addr*)h->h_addr)->s_addr;
 		sip->ip = g_strdup(gaim_network_get_my_ip(sip->listenfd));
 		sip->resendtimeout = gaim_timeout_add(2500, (GSourceFunc)resend_timeout, sip);