On (14/02/14 13:28), Pavel Březina wrote:
>From 7b36b3f479dab7216e52ce6865906f2ce0444bb7 Mon Sep 17 00:00:00 2001
>From: =?UTF-8?q?Pavel=20B=C5=99ezina?= <pbrezina(a)redhat.com>
>Date: Fri, 14 Feb 2014 13:04:31 +0100
>Subject: [PATCH] resolv_gethostbyname_dns_parse(): remove tmp_ctx
>
>Resolves:
>---
> src/resolv/async_resolv.c | 8 ++------
> 1 file changed, 2 insertions(+), 6 deletions(-)
>
>diff --git a/src/resolv/async_resolv.c b/src/resolv/async_resolv.c
>index
9770d3a179b051b0aae4dab6ad8d3057beac8015..439137099e33b7e683a5b6cc2cb810d69d526c15 100644
>--- a/src/resolv/async_resolv.c
>+++ b/src/resolv/async_resolv.c
>@@ -944,15 +944,11 @@ resolv_gethostbyname_dns_parse(struct gethostbyname_dns_state
*state,
> int status, int timeouts,
> unsigned char *abuf, int alen)
> {
>- TALLOC_CTX *tmp_ctx;
> struct hostent *hostent;
> int naddrttls;
> errno_t ret;
> void *addr;
>
>- tmp_ctx = talloc_new(NULL);
>- if (!tmp_ctx) return ENOMEM;
>-
> naddrttls = DNS_HEADER_ANCOUNT(abuf);
>
> switch (state->family) {
>@@ -1007,11 +1003,11 @@ resolv_gethostbyname_dns_parse(struct gethostbyname_dns_state
*state,
> }
> }
>
>- talloc_free(tmp_ctx);
>+ talloc_free(addr);
> return return_code(status);
>
> fail:
>- talloc_free(tmp_ctx);
>+ talloc_free(addr);
> return ret;
Warning from clang static analyser
src/resolv/async_resolv.c:1010:5: warning: Function call argument is an uninitialized
value
talloc_free(addr);
^~~~~~~~~~~~~~~~~
/usr/include/talloc.h:226:26: note: expanded from macro 'talloc_free'
#define talloc_free(ctx) _talloc_free(ctx, __location__)
^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
1 warning generated.
addr would not be initialised in defaul section.
I can see two options:
- initialise addr to NULL
- do not remove tmp_ctx, but to use tmp_ctx for allocation of array.
LS