[asterisk-commits] res resolver unbound.c: Fix frequent ref leak caught by exce... (asterisk[14])

SVN commits to the Asterisk project asterisk-commits at lists.digium.com
Thu Feb 2 08:45:52 CST 2017


Anonymous Coward #1000019 has submitted this change and it was merged. ( https://gerrit.asterisk.org/4866 )

Change subject: res_resolver_unbound.c: Fix frequent ref leak caught by excessive ref trap.
......................................................................


res_resolver_unbound.c: Fix frequent ref leak caught by excessive ref trap.

ASTERISK-26765

Change-Id: I27eb97df7f8d7e624b0b9a61c0fcee4718c86d8d
---
M res/res_resolver_unbound.c
1 file changed, 9 insertions(+), 1 deletion(-)

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



diff --git a/res/res_resolver_unbound.c b/res/res_resolver_unbound.c
index 348e04f..f349852 100644
--- a/res/res_resolver_unbound.c
+++ b/res/res_resolver_unbound.c
@@ -288,13 +288,21 @@
 	ub_resolve_free(ub_result);
 }
 
+static void unbound_resolver_data_dtor(void *vdoomed)
+{
+	struct unbound_resolver_data *doomed = vdoomed;
+
+	ao2_cleanup(doomed->resolver);
+}
+
 static int unbound_resolver_resolve(struct ast_dns_query *query)
 {
 	struct unbound_config *cfg = ao2_global_obj_ref(globals);
 	struct unbound_resolver_data *data;
 	int res;
 
-	data = ao2_alloc_options(sizeof(*data), NULL, AO2_ALLOC_OPT_LOCK_NOLOCK);
+	data = ao2_alloc_options(sizeof(*data), unbound_resolver_data_dtor,
+		AO2_ALLOC_OPT_LOCK_NOLOCK);
 	if (!data) {
 		ast_log(LOG_ERROR, "Failed to allocate resolver data for resolution of '%s'\n",
 			ast_dns_query_get_name(query));

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

Gerrit-MessageType: merged
Gerrit-Change-Id: I27eb97df7f8d7e624b0b9a61c0fcee4718c86d8d
Gerrit-PatchSet: 1
Gerrit-Project: asterisk
Gerrit-Branch: 14
Gerrit-Owner: Richard Mudgett <rmudgett at digium.com>
Gerrit-Reviewer: Anonymous Coward #1000019
Gerrit-Reviewer: George Joseph <gjoseph at digium.com>
Gerrit-Reviewer: Joshua Colp <jcolp at digium.com>



More information about the asterisk-commits mailing list