diff --git a/ares/ares_mkquery.c b/ares/ares_mkquery.c index cfd15a9973998901dfeac304558728d639285321..9c84446e7c070deb32f37dc425428ef3c8ff289c 100644 --- a/ares/ares_mkquery.c +++ b/ares/ares_mkquery.c @@ -88,6 +88,10 @@ int ares_mkquery(const char *name, int dnsclass, int type, unsigned short id, unsigned char *q; const char *p; + /* Set our results early, in case we bail out early with an error. */ + *buflen = 0; + *buf = NULL; + /* Compute the length of the encoded name so we can check buflen. * Start counting at 1 for the zero-length label at the end. */ len = 1;