fix use after free
[project/mdnsd.git] / cache.c
diff --git a/cache.c b/cache.c
index 927b9cf..150fb26 100644 (file)
--- a/cache.c
+++ b/cache.c
@@ -24,7 +24,6 @@
 #include <sys/socket.h>
 #include <netinet/in.h>
 #include <arpa/inet.h>
-#include <asm/byteorder.h>
 #include <arpa/nameser.h>
 #include <resolv.h>
 #include <time.h>
@@ -301,8 +300,8 @@ cache_answer(struct interface *iface, uint8_t *base, int blen, char *name, struc
        r = cache_record_find(name, a->type, port, dlen, rdata);
        if (r) {
                if (!a->ttl) {
-                       cache_record_free(r);
                        DBG(1, "D -> %s %s ttl:%d\n", dns_type_string(r->type), r->record, r->ttl);
+                       cache_record_free(r);
                } else {
                        r->ttl = a->ttl;
                        DBG(1, "A -> %s %s ttl:%d\n", dns_type_string(r->type), r->record, r->ttl);