summaryrefslogtreecommitdiff
path: root/src/or/dns.c
diff options
context:
space:
mode:
Diffstat (limited to 'src/or/dns.c')
-rw-r--r--src/or/dns.c9
1 files changed, 7 insertions, 2 deletions
diff --git a/src/or/dns.c b/src/or/dns.c
index f38b6fff09..1a955cd2aa 100644
--- a/src/or/dns.c
+++ b/src/or/dns.c
@@ -861,8 +861,13 @@ add_answer_to_cache(const char *address, int is_reverse, uint32_t addr,
strlcpy(resolve->address, address, sizeof(resolve->address));
resolve->is_reverse = is_reverse;
if (is_reverse) {
- tor_assert(hostname);
- resolve->result.hostname = tor_strdup(hostname);
+ if (outcome == DNS_RESOLVE_SUCCEEDED) {
+ tor_assert(hostname);
+ resolve->result.hostname = tor_strdup(hostname);
+ } else {
+ tor_assert(! hostname);
+ resolve->result.hostname = NULL;
+ }
} else {
tor_assert(!hostname);
resolve->result.addr = addr;