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.
This commit is contained in:
parent
816f893569
commit
32589cd33e
1 changed files with 10 additions and 2 deletions
|
@ -1672,8 +1672,16 @@ int celt_decode_with_ec_float(CELTDecoder * restrict st, const unsigned char *da
|
|||
|
||||
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;
|
||||
}
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue