If opendmarc_tld_read_file()
cannot open the file, this function will leak memory, that is, it will allocate memory that cannot be recovered, even after calling opendmarc_tld_shutdown()
. Valgrind testing shows the cause of the problem: before opendmarc_tld_read_file()
even attempts to open the file, it allocates an OPENDMARC_HASH_CTX
object. Then opendmarc_tld_read_file()
tries to open the file, and if it fails to open it, it returns immediately, without freeing the OPENDMARC_HASH_CTX
object it has created.
One simple fix: do not allocate the
OPENDMARC_HASH_CTX
object until afteropendmarc_tld_read_file()
has successfully opened the file. The hash is not used before the file is opened, and serves no purpose if the file cannot be opened.The attached patch should fix it - but is untested...