From 8b09633c94cc3aabb1c42c5d4cc43b0af8ecf26b Mon Sep 17 00:00:00 2001 From: Willem Toorop Date: Mon, 20 Mar 2017 11:03:15 +0100 Subject: [PATCH] Bug and mem-leak fix --- .../280-limit_outstanding_queries.Makefile | 2 +- .../280-limit_outstanding_queries.c | 12 +++++++----- 2 files changed, 8 insertions(+), 6 deletions(-) diff --git a/src/test/tpkg/280-limit_outstanding_queries.tpkg/280-limit_outstanding_queries.Makefile b/src/test/tpkg/280-limit_outstanding_queries.tpkg/280-limit_outstanding_queries.Makefile index c297df6d..70d86616 100644 --- a/src/test/tpkg/280-limit_outstanding_queries.tpkg/280-limit_outstanding_queries.Makefile +++ b/src/test/tpkg/280-limit_outstanding_queries.tpkg/280-limit_outstanding_queries.Makefile @@ -2,7 +2,7 @@ builddir = @BUILDDIR@ testname = @TPKG_NAME@ LIBTOOL = $(builddir)/libtool -CFLAGS=-I$(builddir)/src +CFLAGS=-Wall -Wextra -I$(builddir)/src LDLIBS=$(builddir)/src/libgetdns.la .SUFFIXES: .c .o .a .lo .h diff --git a/src/test/tpkg/280-limit_outstanding_queries.tpkg/280-limit_outstanding_queries.c b/src/test/tpkg/280-limit_outstanding_queries.tpkg/280-limit_outstanding_queries.c index 78107b57..1467ec34 100644 --- a/src/test/tpkg/280-limit_outstanding_queries.tpkg/280-limit_outstanding_queries.c +++ b/src/test/tpkg/280-limit_outstanding_queries.tpkg/280-limit_outstanding_queries.c @@ -64,12 +64,12 @@ void delay_cb(void *userarg) void handler(getdns_context *context, getdns_callback_type_t callback_type, getdns_dict *request, void *userarg, getdns_transaction_t request_id) { - transaction_t *trans; + transaction_t *trans = NULL; getdns_bindata *qname; char nreq_str[255]; - getdns_bindata nreq_bd = { 0, nreq_str }; + getdns_bindata nreq_bd = { 0, (void *)nreq_str }; - (void) userarg; + (void) userarg; (void)callback_type; nreq_bd.size = snprintf(nreq_str, sizeof(nreq_str), "n_requests: %d", ++n_requests); if (getdns_dict_get_bindata(request, "/question/qname", &qname) || @@ -83,8 +83,8 @@ void handler(getdns_context *context, getdns_callback_type_t callback_type, qname->data[3] == 'i' && qname->data[4] == 't') { (void) getdns_reply(context, request, request_id); - (void) getdns_context_set_listen_addresses(trans->context, NULL, NULL, NULL); - n_requests -= 1; + (void) getdns_context_set_listen_addresses(context, NULL, NULL, NULL); + getdns_dict_destroy(request); return; } else if (!(trans = malloc(sizeof(transaction_t)))) @@ -102,6 +102,8 @@ void handler(getdns_context *context, getdns_callback_type_t callback_type, fprintf(stderr, "Could not schedule delay\n"); else return; } + getdns_dict_destroy(trans->request); + if (trans) free(trans); exit(EXIT_FAILURE); }