ref: 32589cd33e166ff62d0e842a1a9407542a104e22
parent: 816f89356900199bc688a9d2033dfd00f6e815c8
author: Jean-Marc Valin <[email protected]>
date: Mon May 31 17:56:12 EDT 2010
Trying not to crash on bit errors When the pitch flag gets corrupted, make sure that pitch is actually allowed instead of generating a bogus pitch index and crashing.
--- a/libcelt/celt.c
+++ b/libcelt/celt.c
@@ -1672,8 +1672,16 @@
if (has_pitch)
{
- pitch_index = ec_dec_uint(dec, MAX_PERIOD-(2*N-2*N4));
- gain_id = ec_dec_uint(dec, 16);
+ int maxpitch = MAX_PERIOD-(2*N-2*N4);
+ if (maxpitch<0)
+ {
+ celt_notify("detected pitch when not allowed, bit corruption suspected");
+ pitch_index = 0;
+ has_pitch = 0;
+ } else {
+ pitch_index = ec_dec_uint(dec, maxpitch);
+ gain_id = ec_dec_uint(dec, 16);
+ }
} else {
pitch_index = 0;
}