]> git.ipfire.org Git - thirdparty/unbound.git/commitdiff
fixup memory leak.
authorWouter Wijngaards <wouter@nlnetlabs.nl>
Wed, 27 Jun 2007 11:12:58 +0000 (11:12 +0000)
committerWouter Wijngaards <wouter@nlnetlabs.nl>
Wed, 27 Jun 2007 11:12:58 +0000 (11:12 +0000)
git-svn-id: file:///svn/unbound/trunk@426 be551aaa-1e26-0410-a405-d3ace91eadb9

doc/Changelog
iterator/iter_utils.c
services/cache/dns.c

index 2f7ff4c8aeabebd62b9e568cd954467a52f99813..f14af3928ddeb9da909b78aa29a002fad81c6595 100644 (file)
@@ -1,5 +1,7 @@
 27 June 2007: Wouter
        - delete of mesh does a postorder traverse of the tree.
+       - found and fixed a memory leak. For TTL=0 messages, that would
+         not be cached, instead the msg-replyinfo structure was leaked.
 
 26 June 2007: Wouter
        - mesh is called by worker, and iterator uses it.
index d728cf031fc379b08fb83c271cf7c45f695f21b7..df3decd7974b1ec2061567ba8729efc45c6b5221 100644 (file)
@@ -317,8 +317,10 @@ iter_dns_store(struct module_env* env, struct dns_msg* msg, int is_referral)
 
                qinf = msg->qinfo;
                qinf.qname = memdup(msg->qinfo.qname, msg->qinfo.qname_len);
-               if(!qinf.qname)
+               if(!qinf.qname) {
+                       reply_info_parsedelete(msg->rep, env->alloc);
                        return 0;
+               }
                /* fixup flags to be sensible for a reply based on the cache */
                /* this module means that RA is available. It is an answer QR. 
                 * Not AA from cache. Not CD in cache (depends on client bit). */
@@ -326,6 +328,8 @@ iter_dns_store(struct module_env* env, struct dns_msg* msg, int is_referral)
                rep->flags &= ~(BIT_AA | BIT_CD);
                h = query_info_hash(&qinf);
                dns_cache_store_msg(env, &qinf, h, rep);
+               /* qname is used inside query_info_entrysetup, and set to 
+                * NULL. If it has not been used, free it. free(0) is safe. */
                free(qinf.qname);
        }
        return 1;
index 14cd72263e8d3e0b1a1143f63928deaca7328300..f6045fe170a9eeb7eac4817988bd715324fdf9b8 100644 (file)
@@ -78,8 +78,8 @@ dns_cache_store_msg(struct module_env* env, struct query_info* qinfo,
 
        /* store RRsets */
         for(i=0; i<rep->rrset_count; i++) {
-                rep->ref[i].key = rep->rrsets[i];
-                rep->ref[i].id = rep->rrsets[i]->id;
+               rep->ref[i].key = rep->rrsets[i];
+               rep->ref[i].id = rep->rrsets[i]->id;
        }
        reply_info_sortref(rep);
        reply_info_set_ttls(rep, now);
@@ -88,6 +88,7 @@ dns_cache_store_msg(struct module_env* env, struct query_info* qinfo,
                /* we do not store the message, but we did store the RRs,
                 * which could be useful for delegation information */
                verbose(VERB_ALGO, "TTL 0: dropped msg from cache");
+               free(rep);
                return;
        }