Fix bug in the OPUS_GET_APPLICATION_REQUEST ctl and also add a bunch of set ctl range checking and improve encoder/decoder error code consistency.

This commit is contained in:
Gregory Maxwell 2011-10-01 20:30:16 -04:00
parent 55788c8c85
commit 220a7d4ba8
2 changed files with 52 additions and 17 deletions

View file

@ -88,8 +88,9 @@ int opus_decoder_init(OpusDecoder *st, opus_int32 Fs, int channels)
CELTDecoder *celt_dec;
int ret, silkDecSizeBytes;
if (channels<1 || channels > 2)
if((Fs!=48000&&Fs!=24000&&Fs!=16000&&Fs!=12000&&Fs!=8000)||(channels!=1&&channels!=2))
return OPUS_BAD_ARG;
OPUS_CLEAR((char*)st, opus_decoder_get_size(channels));
/* Initialize SILK encoder */
ret = silk_Get_Decoder_Size(&silkDecSizeBytes);
@ -122,6 +123,12 @@ int opus_decoder_init(OpusDecoder *st, opus_int32 Fs, int channels)
OpusDecoder *opus_decoder_create(opus_int32 Fs, int channels, int *error)
{
int ret;
if((Fs!=48000&&Fs!=24000&&Fs!=16000&&Fs!=12000&&Fs!=8000)||(channels!=1&&channels!=2))
{
if (error)
*error = OPUS_BAD_ARG;
return NULL;
}
OpusDecoder *st = (OpusDecoder *)opus_alloc(opus_decoder_get_size(channels));
if (st == NULL)
{