Handle the case when hoststring is empty.
BUG=chromium:480536 R=magjed@webrtc.org Review URL: https://webrtc-codereview.appspot.com/46109004 Cr-Commit-Position: refs/heads/master@{#9081}
This commit is contained in:
parent
c4188fd3c7
commit
77d444a433
@ -106,8 +106,8 @@ struct GetStatsMsg : public rtc::MessageData {
|
||||
bool GetServiceTypeAndHostnameFromUri(const std::string& in_str,
|
||||
ServiceType* service_type,
|
||||
std::string* hostname) {
|
||||
std::string::size_type colonpos = in_str.find(':');
|
||||
if (colonpos == std::string::npos) {
|
||||
const std::string::size_type colonpos = in_str.find(':');
|
||||
if (colonpos == std::string::npos || (colonpos + 1) == in_str.length()) {
|
||||
return false;
|
||||
}
|
||||
std::string type = in_str.substr(0, colonpos);
|
||||
@ -218,13 +218,19 @@ bool ParseIceServers(const PeerConnectionInterface::IceServers& configuration,
|
||||
continue;
|
||||
}
|
||||
|
||||
ASSERT(!hoststring.empty());
|
||||
|
||||
// Let's break hostname.
|
||||
tokens.clear();
|
||||
rtc::tokenize(hoststring, '@', &tokens);
|
||||
hoststring = tokens[0];
|
||||
if (tokens.size() == kTurnHostTokensNum) {
|
||||
ASSERT(!tokens.empty());
|
||||
// TODO(pthatcher): What's the right thing to do if tokens.size() is >2?
|
||||
// E.g. a string like "foo@bar@bat".
|
||||
if (tokens.size() >= kTurnHostTokensNum) {
|
||||
server.username = rtc::s_url_decode(tokens[0]);
|
||||
hoststring = tokens[1];
|
||||
} else {
|
||||
hoststring = tokens[0];
|
||||
}
|
||||
|
||||
int port = kDefaultStunPort;
|
||||
@ -239,7 +245,6 @@ bool ParseIceServers(const PeerConnectionInterface::IceServers& configuration,
|
||||
continue;
|
||||
}
|
||||
|
||||
|
||||
if (port <= 0 || port > 0xffff) {
|
||||
LOG(WARNING) << "Invalid port: " << port;
|
||||
continue;
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user