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

Unified Diff: runtime/bin/socket_android.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.cc ('k') | runtime/bin/socket_linux.cc » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: runtime/bin/socket_android.cc
diff --git a/runtime/bin/socket_android.cc b/runtime/bin/socket_android.cc
index 39b142b08e5d204f7923cd459294182fa7569904..61dd61ed98537d12ad9ee0095a8aa190a55c5fe0 100644
--- a/runtime/bin/socket_android.cc
+++ b/runtime/bin/socket_android.cc
@@ -25,10 +25,18 @@ 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);
+ 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.cc ('k') | runtime/bin/socket_linux.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698