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

Richard Mudgett asteriskteam at digium.com
Wed Feb 1 17:33:25 CST 2017


Richard Mudgett has uploaded a new change for review. ( 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(-)


  git pull ssh://gerrit.asterisk.org:29418/asterisk refs/changes/66/4866/1

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: newchange
Gerrit-Change-Id: I27eb97df7f8d7e624b0b9a61c0fcee4718c86d8d
Gerrit-PatchSet: 1
Gerrit-Project: asterisk
Gerrit-Branch: 14
Gerrit-Owner: Richard Mudgett <rmudgett at digium.com>



More information about the asterisk-code-review mailing list