[Asterisk-code-review] format_cap: fix reference leak. (asterisk[master])
Jaco Kroon
asteriskteam at digium.com
Tue Mar 9 11:35:24 CST 2021
Jaco Kroon has uploaded this change for review. ( https://gerrit.asterisk.org/c/asterisk/+/15600 )
Change subject: format_cap: fix reference leak.
......................................................................
format_cap: fix reference leak.
format_cap_framed_init decrements the reference count on
format_cap_framed object in all failure paths, and increments it on
success path.
This is inconsistent in that the caller retains a ref on success, but
sacrifices the ref on failure.
Make it consistent such that format_cap_framed_init always takes over
the ref and the caller thus needs to +1 it before passing if it would
like to retain a reference.
The only user I can find is __ast_format_cap_append which already
assumes the new behaviour.
Change-Id: Ib09076f065421c02aab8f7d6716c07344277103b
Signed-off-by: Jaco Kroon <jaco at uls.co.za>
---
M main/format_cap.c
1 file changed, 1 insertion(+), 1 deletion(-)
git pull ssh://gerrit.asterisk.org:29418/asterisk refs/changes/00/15600/1
diff --git a/main/format_cap.c b/main/format_cap.c
index 4dc8e49..467f182 100644
--- a/main/format_cap.c
+++ b/main/format_cap.c
@@ -167,7 +167,7 @@
}
/* Order doesn't matter for formats, so insert at the head for performance reasons */
- ao2_ref(framed, +1);
+ /* No need to ao2_ref(+1) as we take the ref from the constructor */
AST_LIST_INSERT_HEAD(list, framed, entry);
cap->framing = MIN(cap->framing, framing ? framing : ast_format_get_default_ms(format));
--
To view, visit https://gerrit.asterisk.org/c/asterisk/+/15600
To unsubscribe, or for help writing mail filters, visit https://gerrit.asterisk.org/settings
Gerrit-Project: asterisk
Gerrit-Branch: master
Gerrit-Change-Id: Ib09076f065421c02aab8f7d6716c07344277103b
Gerrit-Change-Number: 15600
Gerrit-PatchSet: 1
Gerrit-Owner: Jaco Kroon <jaco at uls.co.za>
Gerrit-MessageType: newchange
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.digium.com/pipermail/asterisk-code-review/attachments/20210309/04e80355/attachment.html>
More information about the asterisk-code-review
mailing list