From e80461fbb501f089fc9a3920a53562293c51e139 Mon Sep 17 00:00:00 2001 From: Andy Green Date: Tue, 24 Oct 2017 19:27:38 +0800 Subject: [PATCH] build: strict-aliasing on old compiler workaround https://github.com/warmcat/libwebsockets/issues/1067 --- lib/libwebsockets.c | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/lib/libwebsockets.c b/lib/libwebsockets.c index 669f4edf8..f57b60a60 100644 --- a/lib/libwebsockets.c +++ b/lib/libwebsockets.c @@ -2281,7 +2281,11 @@ lws_socket_bind(struct lws_vhost *vhost, lws_sockfd_type sockfd, int port, ntohs(((struct sockaddr_in6 *) &sin)->sin6_port) : ntohs(((struct sockaddr_in *) &sin)->sin_port); #else - port = ntohs(((struct sockaddr_in *) &sin)->sin_port); + { + struct sockaddr_in sain; + memcpy(&sain, &sin, sizeof(sain)); + port = ntohs(sain.sin_port); + } #endif #endif