fix use after free
authorJohn Crispin <blogic@openwrt.org>
Wed, 25 Jun 2014 01:09:02 +0000 (02:09 +0100)
committerJohn Crispin <blogic@openwrt.org>
Wed, 25 Jun 2014 01:09:02 +0000 (02:09 +0100)
Signed-off-by: John Crispin <blogic@openwrt.org>
cache.c

diff --git a/cache.c b/cache.c
index adfc8159599048fae46cf12101b92242b42f2833..150fb260905843abec5995172928190d6fdf36e9 100644 (file)
--- a/cache.c
+++ b/cache.c
@@ -300,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);