summaryrefslogtreecommitdiff
path: root/main/format_cap.c
diff options
context:
space:
mode:
authorCorey Farrell <git@cfware.com>2016-01-07 10:39:19 -0500
committerCorey Farrell <git@cfware.com>2016-01-07 10:39:19 -0500
commit5d8c42c6d39eb1261900a80993e874329c694412 (patch)
tree306742f66bc937ee28820426f11ae166a65e9c81 /main/format_cap.c
parent0f87b89b3299f57ba799d4e595ba491a1c171dbf (diff)
ast_format_cap_append_by_type: Resolve codec reference leak.
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
Diffstat (limited to 'main/format_cap.c')
-rw-r--r--main/format_cap.c7
1 files changed, 6 insertions, 1 deletions
diff --git a/main/format_cap.c b/main/format_cap.c
index 9e16aa3e1..d3e87fafd 100644
--- a/main/format_cap.c
+++ b/main/format_cap.c
@@ -218,6 +218,7 @@ int ast_format_cap_append_by_type(struct ast_format_cap *cap, enum ast_media_typ
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;
@@ -238,10 +239,14 @@ int ast_format_cap_append_by_type(struct ast_format_cap *cap, enum ast_media_typ
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) {