Chromium Code Reviews| Index: net/base/ip_address_number.cc |
| diff --git a/net/base/ip_address_number.cc b/net/base/ip_address_number.cc |
| index 1e44b7d3b1ebcc74873fa762eb0ced94411c188d..80cd7e92b3217b9a62924e791f71a7f88469ca9d 100644 |
| --- a/net/base/ip_address_number.cc |
| +++ b/net/base/ip_address_number.cc |
| @@ -102,8 +102,6 @@ std::string IPAddressToString(const uint8_t* address, size_t address_len) { |
| url::AppendIPv4Address(address, &output); |
| } else if (address_len == kIPv6AddressSize) { |
| url::AppendIPv6Address(address, &output); |
| - } else { |
| - CHECK(false) << "Invalid IP address with length: " << address_len; |
| } |
|
martijnc
2016/02/17 21:46:55
Also simplified this. The else clause wasn't neces
|
| output.Complete(); |
| @@ -114,6 +112,8 @@ std::string IPAddressToStringWithPort(const uint8_t* address, |
| size_t address_len, |
| uint16_t port) { |
| std::string address_str = IPAddressToString(address, address_len); |
| + if (address_str.empty()) |
| + return address_str; |
| if (address_len == kIPv6AddressSize) { |
| // Need to bracket IPv6 addresses since they contain colons. |
| @@ -123,17 +123,16 @@ std::string IPAddressToStringWithPort(const uint8_t* address, |
| } |
| std::string IPAddressToString(const IPAddressNumber& addr) { |
| - return IPAddressToString(&addr.front(), addr.size()); |
| + return IPAddressToString(addr.data(), addr.size()); |
| } |
| std::string IPAddressToStringWithPort(const IPAddressNumber& addr, |
| uint16_t port) { |
| - return IPAddressToStringWithPort(&addr.front(), addr.size(), port); |
| + return IPAddressToStringWithPort(addr.data(), addr.size(), port); |
| } |
| std::string IPAddressToPackedString(const IPAddressNumber& addr) { |
| - return std::string(reinterpret_cast<const char *>(&addr.front()), |
| - addr.size()); |
| + return std::string(reinterpret_cast<const char*>(addr.data()), addr.size()); |
| } |
| bool ParseURLHostnameToNumber(const std::string& hostname, |