codec_thread.c don't overrun audio_formats[] array

Change-Id: I58941cea061f41478d7677beb9ff42e28b2455a6
This commit is contained in:
William Wilgus 2021-08-11 10:56:14 -04:00
parent e3e72d6dba
commit 1dd531ff03

View file

@ -183,13 +183,15 @@ const char * get_codec_filename(int cod_spec)
/* Can choose decoder or encoder if one available */
int type = cod_spec & CODEC_TYPE_MASK;
int afmt = cod_spec & CODEC_AFMT_MASK;
int tmp_fmt = afmt;
if ((unsigned)afmt >= AFMT_NUM_CODECS)
{
type = AFMT_UNKNOWN | (type & CODEC_TYPE_MASK);
tmp_fmt = AFMT_UNKNOWN;
}
fname = (type == CODEC_TYPE_ENCODER) ?
audio_formats[afmt].codec_enc_root_fn :
audio_formats[afmt].codec_root_fn;
audio_formats[tmp_fmt].codec_enc_root_fn :
audio_formats[tmp_fmt].codec_root_fn;
logf("%s: %d - %s",
(type == CODEC_TYPE_ENCODER) ? "Encoder" : "Decoder",