From: Matthew Jordan Date: Tue, 17 Apr 2012 21:18:06 +0000 (+0000) Subject: Handle case where an unknown format is used to get the preferred codec size X-Git-Tag: 1.8.13.0-rc1~46 X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=7c0583212e3b65ec8f887a12e0972889e6c9aa2b;p=thirdparty%2Fasterisk.git Handle case where an unknown format is used to get the preferred codec size In ast_codec_pref_getsize, if an unknown format is passed to the method, no preferred codec will be selected and a negative number will be used to index into the format list. The method now logs an unknown format as a warning, and returns an empty format list. (issue ASTERISK-19655) Reported by: Matt Jordan Review: https://reviewboard.asterisk.org/r/1863/ git-svn-id: https://origsvn.digium.com/svn/asterisk/branches/1.8@362368 65c4cc65-6c06-0410-ace0-fbb531ad65f3 --- diff --git a/main/frame.c b/main/frame.c index 9f599a9917..a97ec9cb73 100644 --- a/main/frame.c +++ b/main/frame.c @@ -1195,6 +1195,11 @@ struct ast_format_list ast_codec_pref_getsize(struct ast_codec_pref *pref, forma } } + 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 < ARRAY_LEN(AST_FORMAT_LIST); x++) { if (pref->order[x] == (idx + 1)) { framems = pref->framing[x];