From b918bd858f565c62d0023016178724ce4a95f001 Mon Sep 17 00:00:00 2001 From: Richard Mudgett Date: Wed, 1 Feb 2017 17:14:53 -0600 Subject: [PATCH] res_resolver_unbound.c: Fix frequent ref leak caught by excessive ref trap. ASTERISK-26765 Change-Id: I27eb97df7f8d7e624b0b9a61c0fcee4718c86d8d --- res/res_resolver_unbound.c | 10 +++++++++- 1 file changed, 9 insertions(+), 1 deletion(-) diff --git a/res/res_resolver_unbound.c b/res/res_resolver_unbound.c index 348e04f934..f34985255e 100644 --- a/res/res_resolver_unbound.c +++ b/res/res_resolver_unbound.c @@ -288,13 +288,21 @@ static void unbound_resolver_callback(void *data, int err, struct ub_result *ub_ 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)); -- 2.47.2