[ldns-users] memleak in ldns_rr_list_subtype_by_rdf

Marius Rieder marius.rieder at durchmesser.ch
Tue Jun 30 13:48:52 UTC 2009


Hi

ldns_rr_list_subtype_by_rdf have the same mistake a secount time.
in ldns_rr_list_clone may ldns_rr_list_deep_free should be used. In the
situation that some rr are allready coned it's leak memory if
ldns_rr_clone fails.


Index: rr.c
===================================================================
--- rr.c	(revision 2963)
+++ rr.c	(working copy)
@@ -935,6 +935,7 @@
 			pos);
 		if (!list_rdf) {
 			/* pos is too large or any other error */
+			ldns_rr_list_deep_free(subtyped);
 			return NULL;
 		}
@@ -1265,7 +1268,7 @@
 		    );
 		if (!r) {
 			/* huh, failure in cloning */
-			ldns_rr_list_free(new_list);
+			ldns_rr_list_deep_free(new_list);
 			return NULL;
 		}
 		ldns_rr_list_push_rr(new_list, r);



On 6/29/09 12:31 PM, Marius Rieder wrote:
> Hi
> 
> ldns_rr_list_subtype_by_rdf return NULL if no rr has matched, but don't
> free the created ldns_rr_list *subtyped;
> It's just "24 bytes in 1 blocks." but buged me because my program was
> losing memory.
> 
> Marius
> 
> --- rr.c.orig	2009-06-28 21:48:25.000000000 +0200
> +++ rr.c	2009-06-29 12:26:23.000000000 +0200
> @@ -948,6 +947,7 @@
>  	if (ldns_rr_list_rr_count(subtyped) > 0) {
>  		return subtyped;
>  	} else {
> +		ldns_rr_list_free(subtyped);
>  		return NULL;
>  	}
>  }
> 

-- 
   ~o__O                 Marius Rieder                  O__o~
    |vV|           http://www.durchmesser.ch/           |vV|
   /]  |         <marius.rieder at durchmesser.ch>         |  [\
---/|--|\--------[ Dance first.  Think later. ]--------/|--|\---



More information about the ldns-users mailing list