From: Alexander Traud Date: Mon, 9 Nov 2015 13:04:43 +0000 (+0100) Subject: ast_format_cap: Avoid format creation on module load, use cache instead. X-Git-Tag: 13.7.0-rc1~80^2 X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=f3ac4d8090207dd4440bf279e1d5ce4702aee314;p=thirdparty%2Fasterisk.git ast_format_cap: Avoid format creation on module load, use cache instead. Since Asterisk 13, formats are immutable and cached. However while loading a module like chan_sip, some formats were created instead using cached ones. ASTERISK-25535 #close Change-Id: I479cdc220d5617c840a98f3389b3bd91e91fbd9b --- diff --git a/main/format_cap.c b/main/format_cap.c index 1725e38628..4739efa0a7 100644 --- a/main/format_cap.c +++ b/main/format_cap.c @@ -264,7 +264,10 @@ int ast_format_cap_append_by_type(struct ast_format_cap *cap, enum ast_media_typ continue; } - format = ast_format_create(codec); + format = ast_format_cache_get(codec->name); + if (!format || (codec != ast_format_get_codec(format))) { + format = ast_format_create(codec); + } ao2_ref(codec, -1); if (!format) {