Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(1355)

Unified Diff: runtime/bin/socket_macos.cc

Issue 24269017: Fix bugs in SocketAddress (Closed) Base URL: https://dart.googlecode.com/svn/branches/bleeding_edge/dart
Patch Set: Added Android Created 7 years, 3 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
« no previous file with comments | « runtime/bin/socket_linux.cc ('k') | tests/standalone/io/internet_address_test.dart » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: runtime/bin/socket_macos.cc
diff --git a/runtime/bin/socket_macos.cc b/runtime/bin/socket_macos.cc
index 3b52c09078222288c4fd48547cf121a275e4c80c..6670d48a3c08338985224a117d569b2ff01fed91 100644
--- a/runtime/bin/socket_macos.cc
+++ b/runtime/bin/socket_macos.cc
@@ -26,10 +26,19 @@ namespace bin {
SocketAddress::SocketAddress(struct sockaddr* sockaddr) {
ASSERT(INET6_ADDRSTRLEN >= INET_ADDRSTRLEN);
RawAddr* raw = reinterpret_cast<RawAddr*>(sockaddr);
- const char* result = inet_ntop(sockaddr->sa_family,
- &raw->in.sin_addr,
- as_string_,
- INET6_ADDRSTRLEN);
+ const char* result;
+ if (sockaddr->sa_family == AF_INET) {
+ result = inet_ntop(sockaddr->sa_family,
+ &raw->in.sin_addr,
+ as_string_,
+ INET_ADDRSTRLEN);
+ } else {
+ ASSERT(sockaddr->sa_family == AF_INET6);
+ result = inet_ntop(sockaddr->sa_family,
+ &raw->in6.sin6_addr,
+ as_string_,
+ INET6_ADDRSTRLEN);
+ }
if (result == NULL) as_string_[0] = 0;
memmove(reinterpret_cast<void *>(&addr_),
sockaddr,
« no previous file with comments | « runtime/bin/socket_linux.cc ('k') | tests/standalone/io/internet_address_test.dart » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698