diff --git a/main/format_pref.c b/main/format_pref.c index 852b650350..48fac7731d 100644 --- a/main/format_pref.c +++ b/main/format_pref.c @@ -274,6 +274,11 @@ struct ast_format_list ast_codec_pref_getsize(struct ast_codec_pref *pref, struc } } + if (idx < 0) { + ast_log(AST_LOG_WARNING, "Format %s unknown; unable to get preferred codec packet size\n", ast_getformatname(format)); + return fmt; + } + for (x = 0; x < f_len; x++) { if (pref->order[x] == (idx + 1)) { framems = pref->framing[x];