This resolves a reference leak caused by ASTERISK-25535. The pointer
returned by ast_format_get_codec is saved so it can be released.
ASTERISK-25664 #close
Change-Id: If9941b1bf4320b2c59056546d6bce9422726d1ec
for (id = 1; id < ast_codec_get_max(); ++id) {
struct ast_codec *codec = ast_codec_get_by_id(id);
+ struct ast_codec *codec2 = NULL;
struct ast_format *format;
int res;
continue;
}
- if (!format || (codec != ast_format_get_codec(format))) {
+ if (format) {
+ codec2 = ast_format_get_codec(format);
+ }
+ if (codec != codec2) {
ao2_cleanup(format);
format = ast_format_create(codec);
}
+ ao2_cleanup(codec2);
ao2_ref(codec, -1);
if (!format) {