From: Willem Toorop Date: Fri, 23 Sep 2011 11:49:21 +0000 (+0000) Subject: Code review from Wouter. X-Git-Tag: release-1.6.11~8 X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=8151a57f9141febb0a183e8f1ade6417e0a8ec97;p=thirdparty%2Fldns.git Code review from Wouter. Fix potential memory leak --- diff --git a/host2str.c b/host2str.c index 5679fe07..eff1216a 100644 --- a/host2str.c +++ b/host2str.c @@ -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); }