Menu

#212 opendmarc_tld_read_file() Memory Leak

1.3.2
open
nobody
None
2017-05-21
2017-04-04
No

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.

Discussion

  • Frank J. Lhota

    Frank J. Lhota - 2017-04-04

    One simple fix: do not allocate the OPENDMARC_HASH_CTX object until after opendmarc_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.

     
  • Juri Haberland

    Juri Haberland - 2017-05-21

    The attached patch should fix it - but is untested...

     

Log in to post a comment.