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

Unified Diff: webrtc/modules/audio_coding/codecs/ilbc/ilbc.c

Issue 2255203002: iLBC: Handle a case of bad input data (Closed) Base URL: https://chromium.googlesource.com/external/webrtc.git@master
Patch Set: bool test Created 4 years, 4 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
Index: webrtc/modules/audio_coding/codecs/ilbc/ilbc.c
diff --git a/webrtc/modules/audio_coding/codecs/ilbc/ilbc.c b/webrtc/modules/audio_coding/codecs/ilbc/ilbc.c
index 6cd9a723fdbb5398508bacc006e31ad56c1313e2..6587e4f3f7a4933c457a897723333ac35c566467 100644
--- a/webrtc/modules/audio_coding/codecs/ilbc/ilbc.c
+++ b/webrtc/modules/audio_coding/codecs/ilbc/ilbc.c
@@ -22,6 +22,7 @@
#include "encode.h"
#include "init_decode.h"
#include "decode.h"
+#include "webrtc/base/checks.h"
#include <stdlib.h>
int16_t WebRtcIlbcfix_EncoderAssign(IlbcEncoderInstance** iLBC_encinst,
@@ -180,11 +181,12 @@ int WebRtcIlbcfix_Decode(IlbcDecoderInstance* iLBCdec_inst,
}
while ((i*((IlbcDecoder*)iLBCdec_inst)->no_of_bytes)<len) {
- WebRtcIlbcfix_DecodeImpl(
- &decoded[i * ((IlbcDecoder*)iLBCdec_inst)->blockl],
- (const uint16_t*)&encoded
- [2 * i * ((IlbcDecoder*)iLBCdec_inst)->no_of_words],
- (IlbcDecoder*)iLBCdec_inst, 1);
+ if (WebRtcIlbcfix_DecodeImpl(
+ &decoded[i * ((IlbcDecoder*)iLBCdec_inst)->blockl],
+ (const uint16_t*)&encoded
+ [2 * i * ((IlbcDecoder*)iLBCdec_inst)->no_of_words],
+ (IlbcDecoder*)iLBCdec_inst, 1) == -1)
+ return -1;
i++;
}
/* iLBC does not support VAD/CNG yet */
@@ -208,11 +210,12 @@ int WebRtcIlbcfix_Decode20Ms(IlbcDecoderInstance* iLBCdec_inst,
}
while ((i*((IlbcDecoder*)iLBCdec_inst)->no_of_bytes)<len) {
- WebRtcIlbcfix_DecodeImpl(
+ if (!WebRtcIlbcfix_DecodeImpl(
&decoded[i * ((IlbcDecoder*)iLBCdec_inst)->blockl],
(const uint16_t*)&encoded
[2 * i * ((IlbcDecoder*)iLBCdec_inst)->no_of_words],
- (IlbcDecoder*)iLBCdec_inst, 1);
+ (IlbcDecoder*)iLBCdec_inst, 1))
+ return -1;
i++;
}
/* iLBC does not support VAD/CNG yet */
@@ -236,11 +239,12 @@ int WebRtcIlbcfix_Decode30Ms(IlbcDecoderInstance* iLBCdec_inst,
}
while ((i*((IlbcDecoder*)iLBCdec_inst)->no_of_bytes)<len) {
- WebRtcIlbcfix_DecodeImpl(
+ if (!WebRtcIlbcfix_DecodeImpl(
&decoded[i * ((IlbcDecoder*)iLBCdec_inst)->blockl],
(const uint16_t*)&encoded
[2 * i * ((IlbcDecoder*)iLBCdec_inst)->no_of_words],
- (IlbcDecoder*)iLBCdec_inst, 1);
+ (IlbcDecoder*)iLBCdec_inst, 1))
+ return -1;
i++;
}
/* iLBC does not support VAD/CNG yet */
@@ -255,10 +259,11 @@ size_t WebRtcIlbcfix_DecodePlc(IlbcDecoderInstance* iLBCdec_inst,
uint16_t dummy;
for (i=0;i<noOfLostFrames;i++) {
- /* call decoder */
- WebRtcIlbcfix_DecodeImpl(
+ // PLC decoding shouldn't fail, because there is no external input data
+ // that can be bad.
+ RTC_CHECK(WebRtcIlbcfix_DecodeImpl(
&decoded[i * ((IlbcDecoder*)iLBCdec_inst)->blockl], &dummy,
- (IlbcDecoder*)iLBCdec_inst, 0);
+ (IlbcDecoder*)iLBCdec_inst, 0));
}
return (noOfLostFrames*((IlbcDecoder*)iLBCdec_inst)->blockl);
}
« no previous file with comments | « webrtc/modules/audio_coding/codecs/ilbc/get_cd_vec.c ('k') | webrtc/modules/audio_coding/codecs/ilbc/ilbc.gypi » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698