diff options
author | Corey Farrell <git@cfware.com> | 2017-11-06 16:07:01 -0500 |
---|---|---|
committer | Corey Farrell <git@cfware.com> | 2017-11-06 16:07:01 -0500 |
commit | e43c8af77cd3c2a40cd4a02419b574373c18ee85 (patch) | |
tree | e28fa9fa9ff1c308927af702072f1995e81fd20e /main | |
parent | 637b37fb980822f50966f5292a786d03a859cd89 (diff) |
format_cap: Fix leak on AST_VECTOR_APPEND error.
format_cap_framed_init can fail on AST_VECTOR_APPEND. This should
report failure to the caller and clean the newly allocated frame.
Change-Id: Ica0661235bf09497bf23d844ceb01f21b41a55b0
Diffstat (limited to 'main')
-rw-r--r-- | main/format_cap.c | 9 |
1 files changed, 6 insertions, 3 deletions
diff --git a/main/format_cap.c b/main/format_cap.c index b0897c001..d71ccdbaa 100644 --- a/main/format_cap.c +++ b/main/format_cap.c @@ -160,13 +160,16 @@ static inline int format_cap_framed_init(struct format_cap_framed *framed, struc } list = AST_VECTOR_GET_ADDR(&cap->formats, ast_format_get_codec_id(format)); + /* This takes the allocation reference */ + if (AST_VECTOR_APPEND(&cap->preference_order, framed)) { + ao2_ref(framed, -1); + return -1; + } + /* Order doesn't matter for formats, so insert at the head for performance reasons */ ao2_ref(framed, +1); AST_LIST_INSERT_HEAD(list, framed, entry); - /* This takes the allocation reference */ - AST_VECTOR_APPEND(&cap->preference_order, framed); - cap->framing = MIN(cap->framing, framing ? framing : ast_format_get_default_ms(format)); return 0; |