The IDN to text display call back could leak the memory holding the
converted name if it did not fit into the buffer. This has been fixed.
char *dst = NULL;
size_t srclen, dstlen;
int res;
+ isc_result_t result;
/*
* Copy name from 'buffer' to 'src' and terminate it with NULL.
}
resetlocale(LC_ALL);
if (res != IDN2_OK) {
- return ISC_R_SUCCESS;
+ CLEANUP(ISC_R_SUCCESS);
}
/*
*/
dstlen = strlen(dst);
if (isc_buffer_length(buffer) < start + dstlen) {
- return ISC_R_NOSPACE;
+ CLEANUP(ISC_R_NOSPACE);
}
isc_buffer_subtract(buffer, srclen);
memmove(isc_buffer_used(buffer), dst, dstlen);
isc_buffer_add(buffer, dstlen);
- idn2_free(dst);
- return ISC_R_SUCCESS;
+ result = ISC_R_SUCCESS;
+cleanup:
+ if (dst != NULL) {
+ idn2_free(dst);
+ }
+ return result;
}
/*%