[asterisk-commits] ast format cap append by type: Resolve codec reference leak. (asterisk[master])

SVN commits to the Asterisk project asterisk-commits at lists.digium.com
Thu Jan 7 11:30:04 CST 2016


Joshua Colp has submitted this change and it was merged.

Change subject: ast_format_cap_append_by_type: Resolve codec reference leak.
......................................................................


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
---
M main/format_cap.c
1 file changed, 6 insertions(+), 1 deletion(-)

Approvals:
  Richard Mudgett: Looks good to me, but someone else must approve
  Anonymous Coward #1000019: Verified
  Joshua Colp: Looks good to me, approved



diff --git a/main/format_cap.c b/main/format_cap.c
index 9e16aa3..d3e87fa 100644
--- a/main/format_cap.c
+++ b/main/format_cap.c
@@ -218,6 +218,7 @@
 
 	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 @@
 			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) {

-- 
To view, visit https://gerrit.asterisk.org/1925
To unsubscribe, visit https://gerrit.asterisk.org/settings

Gerrit-MessageType: merged
Gerrit-Change-Id: If9941b1bf4320b2c59056546d6bce9422726d1ec
Gerrit-PatchSet: 1
Gerrit-Project: asterisk
Gerrit-Branch: master
Gerrit-Owner: Corey Farrell <git at cfware.com>
Gerrit-Reviewer: Anonymous Coward #1000019
Gerrit-Reviewer: Corey Farrell <git at cfware.com>
Gerrit-Reviewer: Joshua Colp <jcolp at digium.com>
Gerrit-Reviewer: Richard Mudgett <rmudgett at digium.com>



More information about the asterisk-commits mailing list