From 928de0934501565233b1fb25f225cb19b43f7d29 Mon Sep 17 00:00:00 2001 From: Tatsuhiro Tsujikawa Date: Sun, 15 Nov 2009 13:27:46 +0000 Subject: [PATCH] 2009-11-15 Tatsuhiro Tsujikawa Copied in_addr instead of just casting from char* which might violate strict aliasing rules. * src/AsyncNameResolver.cc --- ChangeLog | 6 ++++++ src/AsyncNameResolver.cc | 5 +++-- 2 files changed, 9 insertions(+), 2 deletions(-) diff --git a/ChangeLog b/ChangeLog index 7c338979..185ecf7a 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,3 +1,9 @@ +2009-11-15 Tatsuhiro Tsujikawa + + Copied in_addr instead of just casting from char* which might + violate strict aliasing rules. + * src/AsyncNameResolver.cc + 2009-11-15 Tatsuhiro Tsujikawa Use dynamic_pointer_cast diff --git a/src/AsyncNameResolver.cc b/src/AsyncNameResolver.cc index 311353ea..71dd88d4 100644 --- a/src/AsyncNameResolver.cc +++ b/src/AsyncNameResolver.cc @@ -56,8 +56,9 @@ void callback(void* arg, int status, struct hostent* host) return; } for(char** ap = host->h_addr_list; *ap; ++ap) { - resolverPtr->_resolvedAddresses.push_back - (inet_ntoa(*reinterpret_cast(*ap))); + struct in_addr addr; + memcpy(&addr, *ap, sizeof(in_addr)); + resolverPtr->_resolvedAddresses.push_back(inet_ntoa(addr)); } resolverPtr->status = AsyncNameResolver::STATUS_SUCCESS; }