[tex-live] memory leak with kpathsea_find_file() ?

Vincent Torri vincent.torri at gmail.com
Sun Jun 26 22:01:50 CEST 2016


hello

my little library uses kpathsea_find_file(). The actual code to retrieve
the full path of a TFM file is the following:

-------------
    kpathsea kpse;
    char *n;

    kpse = kpathsea_new();
    kpathsea_set_program_name(kpse, "kpsewhich", NULL);
    kpathsea_init_prog (kpse, "LIBDVI", 300, NULL, NULL);
    n = kpathsea_find_file(kpse, name, kpse_tfm_format, 1);
    kpathsea_finish(kpse);
-------------

Drmemory (or valgrind) reports the following unfreed memory :

# 1 ll!xmalloc                          +0x16
# 2 ll!hash_create                      +0x11
# 3 ll!concatn                          +0x8a0
# 4 ll!kpathsea_cnf_get                 +0x2e
# 5 ll!kpathsea_var_value               +0xa5
# 6 ll!kpse_set_suffixes                +0x54
# 7 ll!kpathsea_init_format_return_varlist+0x1f0
# 8 ll!kpathsea_find_file_generic       +0x70
# 9 ll!kpathsea_find_file               +0x1b
#10 dvi_kpathsea_path_name_get           [src/lib/dvi_kpathsea.c:354]
#11 dvi_font_define                      [src/lib/dvi_font.c:332]

trying to free 'n' with free() leads to errors in drmemory (or valgrind).

Is this unfreed memory normal ? or my code is not fully correct ?

thank you

Vincent Torri
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://tug.org/pipermail/tex-live/attachments/20160626/c8b16c09/attachment.html>


More information about the tex-live mailing list