]> git.ipfire.org Git - thirdparty/ldns.git/commitdiff
Code review from Wouter.
authorWillem Toorop <willem@NLnetLabs.nl>
Fri, 23 Sep 2011 11:49:21 +0000 (11:49 +0000)
committerWillem Toorop <willem@NLnetLabs.nl>
Fri, 23 Sep 2011 11:49:21 +0000 (11:49 +0000)
Fix potential memory leak

host2str.c

index 5679fe075ab0bdc975ee6afba3a2ca4933159494..eff1216a966234036e18a5506192344aabdcc335 100644 (file)
@@ -1167,13 +1167,15 @@ ldns_b32_ext2dname(const ldns_rdf *rdf)
        size = ldns_b32_ntop_calculate_size(ldns_rdf_size(rdf) - 1);
         /* add one for the end nul for the string */
        b32 = LDNS_XMALLOC(char, size + 2);
-       if (b32 && ldns_b32_ntop_extended_hex(ldns_rdf_data(rdf) + 1, 
+       if (b32) {
+               if (ldns_b32_ntop_extended_hex(ldns_rdf_data(rdf) + 1, 
                                ldns_rdf_size(rdf) - 1, b32, size+1) > 0) {
-               b32[size] = '.';
-               b32[size+1] = '\0';
-               if (ldns_str2rdf_dname(&out, b32) == LDNS_STATUS_OK) {
-                       LDNS_FREE(b32);
-                       return out;
+                       b32[size] = '.';
+                       b32[size+1] = '\0';
+                       if (ldns_str2rdf_dname(&out, b32) == LDNS_STATUS_OK) {
+                               LDNS_FREE(b32);
+                               return out;
+                       }
                }
                LDNS_FREE(b32);
        }