Memory leak in dirvote.c : dirvote_compute_consensuses()
Just after starting my node with Valgrind, it detects a memory leak:
==90933== 201 (+67) bytes in 6 (+2) blocks are definitely lost in loss record 1,610 of 2,179
==90933== at 0x483B7F3: malloc (in /usr/lib/x86_64-linux-gnu/valgrind/vgpreload_memcheck-amd64-linux.so)
==90933== by 0x4E2DC47: __vasprintf_internal (vasprintf.c:71)
==90933== by 0x23F1BE: tor_vasprintf (printf.c:102)
==90933== by 0x23F117: tor_asprintf (printf.c:80)
==90933== by 0x39F074: options_get_dir_fname2_suffix (config.c:7184)
==90933== by 0x40629E: dirvote_compute_consensuses (dirvote.c:3531)
==90933== by 0x4043DD: dirvote_act (dirvote.c:2939)
==90933== by 0x3EBE59: dirvote_callback (dirauth_periodic.c:68)
==90933== by 0x19918E: periodic_event_dispatch (periodic.c:70)
==90933== by 0x21ED4F: mainloop_event_cb (compat_libevent.c:335)
==90933== by 0x49DDFDD: ??? (in /usr/lib/x86_64-linux-gnu/libevent-2.1.so.7.0.0)
==90933== by 0x49DE87E: event_base_loop (in /usr/lib/x86_64-linux-gnu/libevent-2.1.so.7.0.0)
Here is the concerned line: write_str_to_file(get_datadir_fname(filename), consensus_body, 0);
This issue exists because the get_datadir_fname
macro returns a pointer to a newly allocated area that is never freed after being passed to write_str_to_file()