mirror of https://github.com/getdnsapi/getdns.git
Bug and mem-leak fix
This commit is contained in:
parent
5ea181172a
commit
8b09633c94
|
@ -2,7 +2,7 @@ builddir = @BUILDDIR@
|
||||||
testname = @TPKG_NAME@
|
testname = @TPKG_NAME@
|
||||||
LIBTOOL = $(builddir)/libtool
|
LIBTOOL = $(builddir)/libtool
|
||||||
|
|
||||||
CFLAGS=-I$(builddir)/src
|
CFLAGS=-Wall -Wextra -I$(builddir)/src
|
||||||
LDLIBS=$(builddir)/src/libgetdns.la
|
LDLIBS=$(builddir)/src/libgetdns.la
|
||||||
|
|
||||||
.SUFFIXES: .c .o .a .lo .h
|
.SUFFIXES: .c .o .a .lo .h
|
||||||
|
|
|
@ -64,12 +64,12 @@ void delay_cb(void *userarg)
|
||||||
void handler(getdns_context *context, getdns_callback_type_t callback_type,
|
void handler(getdns_context *context, getdns_callback_type_t callback_type,
|
||||||
getdns_dict *request, void *userarg, getdns_transaction_t request_id)
|
getdns_dict *request, void *userarg, getdns_transaction_t request_id)
|
||||||
{
|
{
|
||||||
transaction_t *trans;
|
transaction_t *trans = NULL;
|
||||||
getdns_bindata *qname;
|
getdns_bindata *qname;
|
||||||
char nreq_str[255];
|
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);
|
nreq_bd.size = snprintf(nreq_str, sizeof(nreq_str), "n_requests: %d", ++n_requests);
|
||||||
|
|
||||||
if (getdns_dict_get_bindata(request, "/question/qname", &qname) ||
|
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') {
|
qname->data[3] == 'i' && qname->data[4] == 't') {
|
||||||
|
|
||||||
(void) getdns_reply(context, request, request_id);
|
(void) getdns_reply(context, request, request_id);
|
||||||
(void) getdns_context_set_listen_addresses(trans->context, NULL, NULL, NULL);
|
(void) getdns_context_set_listen_addresses(context, NULL, NULL, NULL);
|
||||||
n_requests -= 1;
|
getdns_dict_destroy(request);
|
||||||
return;
|
return;
|
||||||
|
|
||||||
} else if (!(trans = malloc(sizeof(transaction_t))))
|
} 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");
|
fprintf(stderr, "Could not schedule delay\n");
|
||||||
else return;
|
else return;
|
||||||
}
|
}
|
||||||
|
getdns_dict_destroy(trans->request);
|
||||||
|
if (trans) free(trans);
|
||||||
exit(EXIT_FAILURE);
|
exit(EXIT_FAILURE);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue