static void ParseAnswerA(AsyncIO *IO, unsigned char* abuf, int alen)
{
- struct hostent* host;
+ struct hostent* host = NULL;
#ifdef DEBUG_CARES
EV_syslog(LOG_DEBUG, "C-ARES: %s\n", __FUNCTION__);
#endif
NULL,
NULL);
if (IO->DNS.Query->DNSStatus != ARES_SUCCESS) {
+ if (host != NULL)
+ ares_free_hostent(host);
StrBufPlain(IO->ErrMsg,
ares_strerror(IO->DNS.Query->DNSStatus), -1);
return;
static void ParseAnswerAAAA(AsyncIO *IO, unsigned char* abuf, int alen)
{
- struct hostent* host;
+ struct hostent* host = NULL;
#ifdef DEBUG_CARES
EV_syslog(LOG_DEBUG, "C-ARES: %s\n", __FUNCTION__);
#endif
NULL,
NULL);
if (IO->DNS.Query->DNSStatus != ARES_SUCCESS) {
+ if (host != NULL)
+ ares_free_hostent(host);
StrBufPlain(IO->ErrMsg,
ares_strerror(IO->DNS.Query->DNSStatus), -1);
return;
static void ParseAnswerCNAME(AsyncIO *IO, unsigned char* abuf, int alen)
{
- struct hostent* host;
+ struct hostent* host = NULL;
#ifdef DEBUG_CARES
EV_syslog(LOG_DEBUG, "C-ARES: %s\n", __FUNCTION__);
NULL,
NULL);
if (IO->DNS.Query->DNSStatus != ARES_SUCCESS) {
+ if (host != NULL)
+ ares_free_hostent(host);
StrBufPlain(IO->ErrMsg,
ares_strerror(IO->DNS.Query->DNSStatus), -1);
return;
static void ParseAnswerMX(AsyncIO *IO, unsigned char* abuf, int alen)
{
- struct ares_mx_reply *mx_out;
+ struct ares_mx_reply *mx_out = NULL;
#ifdef DEBUG_CARES
EV_syslog(LOG_DEBUG, "C-ARES: %s\n", __FUNCTION__);
#endif
IO->DNS.Query->DNSStatus = ares_parse_mx_reply(abuf, alen, &mx_out);
if (IO->DNS.Query->DNSStatus != ARES_SUCCESS) {
+ if (mx_out != NULL)
+ ares_free_data(mx_out);
StrBufPlain(IO->ErrMsg,
ares_strerror(IO->DNS.Query->DNSStatus), -1);
return;
static void ParseAnswerNS(AsyncIO *IO, unsigned char* abuf, int alen)
{
- struct hostent* host;
+ struct hostent* host = NULL;
#ifdef DEBUG_CARES
EV_syslog(LOG_DEBUG, "C-ARES: %s\n", __FUNCTION__);
#endif
IO->DNS.Query->DNSStatus = ares_parse_ns_reply(abuf, alen, &host);
if (IO->DNS.Query->DNSStatus != ARES_SUCCESS) {
+ if (host != NULL)
+ ares_free_hostent(host);
StrBufPlain(IO->ErrMsg,
ares_strerror(IO->DNS.Query->DNSStatus), -1);
return;
static void ParseAnswerSRV(AsyncIO *IO, unsigned char* abuf, int alen)
{
- struct ares_srv_reply *srv_out;
+ struct ares_srv_reply *srv_out = NULL;
#ifdef DEBUG_CARES
EV_syslog(LOG_DEBUG, "C-ARES: %s\n", __FUNCTION__);
#endif
IO->DNS.Query->DNSStatus = ares_parse_srv_reply(abuf, alen, &srv_out);
if (IO->DNS.Query->DNSStatus != ARES_SUCCESS) {
+ if (srv_out != NULL)
+ ares_free_data(srv_out);
StrBufPlain(IO->ErrMsg,
ares_strerror(IO->DNS.Query->DNSStatus), -1);
return;
IO->DNS.Query->DNSStatus = ares_parse_txt_reply(abuf, alen, &txt_out);
if (IO->DNS.Query->DNSStatus != ARES_SUCCESS) {
+ if (txt_out != NULL)
+ ares_free_data(txt_out);
StrBufPlain(IO->ErrMsg,
ares_strerror(IO->DNS.Query->DNSStatus), -1);
return;