getaddrinfo: Fix resource leak after strdup failure in gethosts [BZ #25425]

Filip Ochnik spotted that one of the error jumps in gethosts fails to
call __resolv_context_put to release the resolver context.

Fixes commit 352f4ff9a2 ("resolv:
Introduce struct resolv_context [BZ #21668]") and commit
964263bb8d ("getaddrinfo: Release
resolver context on error in gethosts [BZ #21885]").

Reviewed-by: Siddhesh Poyarekar <siddhesh@sourceware.org>
This commit is contained in:
Florian Weimer 2020-01-20 18:37:13 +01:00
parent 92ce43eef7
commit 8b222fa387

View File

@ -288,6 +288,7 @@ convert_hostent_to_gaih_addrtuple (const struct addrinfo *req,
canonbuf = __strdup (localcanon); \
if (canonbuf == NULL) \
{ \
__resolv_context_put (res_ctx); \
result = -EAI_SYSTEM; \
goto free_and_return; \
} \