]> sourceware.org Git - glibc.git/commitdiff
getaddrinfo: Fix resource leak after strdup failure in gethosts [BZ #25425]
authorFlorian Weimer <fweimer@redhat.com>
Mon, 20 Jan 2020 17:37:13 +0000 (18:37 +0100)
committerFlorian Weimer <fweimer@redhat.com>
Mon, 20 Jan 2020 17:37:13 +0000 (18:37 +0100)
Filip Ochnik spotted that one of the error jumps in gethosts fails to
call __resolv_context_put to release the resolver context.

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

Reviewed-by: Siddhesh Poyarekar <siddhesh@sourceware.org>
sysdeps/posix/getaddrinfo.c

index f813d85aa39d80a9f23f95368854213ebd60b46b..538691a59867e2868ce3a5a9da69f5e26472c4b5 100644 (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;                                           \
            }                                                                 \
This page took 0.041737 seconds and 5 git commands to generate.