Index: webrtc/api/webrtcsdp.cc |
diff --git a/webrtc/api/webrtcsdp.cc b/webrtc/api/webrtcsdp.cc |
index 4a296d9ce2e28a274377e3ca79e727f45c5b6e91..ff68bda46e5026d98b6e58d86c15fdb8e23829b4 100644 |
--- a/webrtc/api/webrtcsdp.cc |
+++ b/webrtc/api/webrtcsdp.cc |
@@ -1291,9 +1291,9 @@ void BuildMediaDescription(const ContentInfo* content_info, |
// RFC 4566 |
// b=AS:<bandwidth> |
- if (media_desc->bandwidth() >= 1000) { |
+ if (media_desc->bandwidth() && (*media_desc->bandwidth() >= 1000)) { |
InitLine(kLineTypeSessionBandwidth, kApplicationSpecificMaximum, &os); |
- os << kSdpDelimiterColon << (media_desc->bandwidth() / 1000); |
+ os << kSdpDelimiterColon << (*media_desc->bandwidth() / 1000); |
AddLine(os.str(), message); |
} |
@@ -2553,6 +2553,12 @@ bool ParseContent(const std::string& message, |
if (!GetValueFromString(line, bandwidth, &b, error)) { |
return false; |
} |
+ if (b < 0) { |
+ std::ostringstream description; |
+ description << "The bandwidth value must not be negative"; |
+ return ParseFailed(line, description.str(), error); |
+ } |
+ |
// We should never use more than the default bandwidth for RTP-based |
// data channels. Don't allow SDP to set the bandwidth, because |
// that would give JS the opportunity to "break the Internet". |
@@ -2564,7 +2570,7 @@ bool ParseContent(const std::string& message, |
<< cricket::kDataMaxBandwidth / 1000 << "kbps."; |
return ParseFailed(line, description.str(), error); |
} |
- media_desc->set_bandwidth(b * 1000); |
+ media_desc->set_bandwidth(rtc::Optional<int>(b * 1000)); |
} |
} |
continue; |