libpurple/protocols/jabber/disco.c

changeset 35676
d9fdd45925ec
parent 34935
686fa55b0deb
child 37423
d2f0259aa43f
child 37457
0b957b80c46a
--- a/libpurple/protocols/jabber/disco.c	Mon Mar 31 23:58:05 2014 +0200
+++ b/libpurple/protocols/jabber/disco.c	Thu Apr 03 00:47:13 2014 +0200
@@ -436,18 +436,20 @@
 	}
 
 	if (hosts && g_slist_next(hosts)) {
-		struct sockaddr *addr = g_slist_next(hosts)->data;
+		common_sockaddr_t addr;
 		char dst[INET6_ADDRSTRLEN];
 		int port;
 
-		if (addr->sa_family == AF_INET6) {
-			inet_ntop(addr->sa_family, &((struct sockaddr_in6 *) addr)->sin6_addr,
+		memcpy(&addr, g_slist_next(hosts)->data, sizeof(addr));
+
+		if (addr.sa.sa_family == AF_INET6) {
+			inet_ntop(addr.sa.sa_family, &addr.in6.sin6_addr,
 				dst, sizeof(dst));
-			port = ntohs(((struct sockaddr_in6 *) addr)->sin6_port);
+			port = ntohs(addr.in6.sin6_port);
 		} else {
-			inet_ntop(addr->sa_family, &((struct sockaddr_in *) addr)->sin_addr,
+			inet_ntop(addr.sa.sa_family, &addr.in.sin_addr,
 				dst, sizeof(dst));
-			port = ntohs(((struct sockaddr_in *) addr)->sin_port);
+			port = ntohs(addr.in.sin_port);
 		}
 
 		if (js->stun_ip)

mercurial