Correctly handle the error case where the CodecId has a negative value

Negative values should be treated the same as too-large positive values: by returning an empty Maybe.

TBR=henrik.lundin@webrtc.org

Review URL: https://codereview.webrtc.org/1407383010

Cr-Commit-Position: refs/heads/master@{#10509}
This commit is contained in:
kwiberg
2015-11-04 09:56:17 -08:00
committed by Commit bot
parent 5d4e944391
commit 98cc88c873

View File

@ -133,8 +133,8 @@ class RentACodec {
static inline rtc::Maybe<int> CodecIndexFromId(CodecId codec_id) {
const int i = static_cast<int>(codec_id);
return i < static_cast<int>(NumberOfCodecs()) ? rtc::Maybe<int>(i)
: rtc::Maybe<int>();
return i >= 0 && i < static_cast<int>(NumberOfCodecs()) ? rtc::Maybe<int>(i)
: rtc::Maybe<int>();
}
static inline rtc::Maybe<CodecId> CodecIdFromIndex(int codec_index) {