From b0855f75f5536498a8261270e09cef010ec9cb86 Mon Sep 17 00:00:00 2001 From: Steffen Jaeckel Date: Thu, 19 Jan 2023 10:30:08 +0100 Subject: [PATCH] don't return RR list on error The resolver maybe returned an error code but allocated an RR list. Free this list now in the resolver instead of depending on the user to free it even though there was an error. This API is only library internal, but still it makes more sense like that. This issue was discovered in CI job [0]. [0] https://github.com/strophe/libstrophe/actions/runs/3874980845/jobs/6776501943 Signed-off-by: Steffen Jaeckel --- src/resolver.c | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/src/resolver.c b/src/resolver.c index 1e02fc7..f6fa409 100644 --- a/src/resolver.c +++ b/src/resolver.c @@ -158,6 +158,10 @@ int resolver_srv_lookup_buf(xmpp_ctx_t *ctx, set = resolver_ares_srv_lookup_buf(ctx, buf, len, srv_rr_list); #else set = resolver_raw_srv_lookup_buf(ctx, buf, len, srv_rr_list); + if (set != XMPP_DOMAIN_FOUND && *srv_rr_list != NULL) { + resolver_srv_free(ctx, *srv_rr_list); + *srv_rr_list = NULL; + } #endif resolver_srv_list_sort(srv_rr_list);