[Asterisk-code-review] format cap: Fix leak on AST VECTOR APPEND error. (asterisk[13])
Corey Farrell
asteriskteam at digium.com
Mon Nov 6 15:12:13 CST 2017
Corey Farrell has uploaded this change for review. ( https://gerrit.asterisk.org/7033
Change subject: format_cap: Fix leak on AST_VECTOR_APPEND error.
......................................................................
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
---
M main/format_cap.c
1 file changed, 6 insertions(+), 3 deletions(-)
git pull ssh://gerrit.asterisk.org:29418/asterisk refs/changes/33/7033/1
diff --git a/main/format_cap.c b/main/format_cap.c
index fc56866..8a00ed6 100644
--- a/main/format_cap.c
+++ b/main/format_cap.c
@@ -177,12 +177,15 @@
}
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));
--
To view, visit https://gerrit.asterisk.org/7033
To unsubscribe, visit https://gerrit.asterisk.org/settings
Gerrit-Project: asterisk
Gerrit-Branch: 13
Gerrit-MessageType: newchange
Gerrit-Change-Id: Ica0661235bf09497bf23d844ceb01f21b41a55b0
Gerrit-Change-Number: 7033
Gerrit-PatchSet: 1
Gerrit-Owner: Corey Farrell <git at cfware.com>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.digium.com/pipermail/asterisk-code-review/attachments/20171106/bb8af4de/attachment.html>
More information about the asterisk-code-review
mailing list