[Asterisk-code-review] res resolver unbound.c: Fix frequent ref leak caught by exce... (asterisk[master])

George Joseph asteriskteam at digium.com
Thu Feb 2 09:00:49 CST 2017


George Joseph has submitted this change and it was merged. ( https://gerrit.asterisk.org/4867 )

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 1877bbc..3c78050 100644
--- a/res/res_resolver_unbound.c
+++ b/res/res_resolver_unbound.c
@@ -286,13 +286,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/4867
To unsubscribe, visit https://gerrit.asterisk.org/settings

Gerrit-MessageType: merged
Gerrit-Change-Id: I27eb97df7f8d7e624b0b9a61c0fcee4718c86d8d
Gerrit-PatchSet: 1
Gerrit-Project: asterisk
Gerrit-Branch: master
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-code-review mailing list