bug#79328: expr: memory not freed before program exit(memory leak)

yubiao hu <[email protected]>
Newsgroups gmane.comp.gnu.core-utils.bugs
Message-ID <CADzWzW_bdmYJb0fkNv5+6mc2o+8FjWV=i0ua+c2jseOGwGUPPQ@mail.gmail.com>
Package: coreutils
Version: 9.4
Severity: normal

I was trying to build coreutils with ASan, and found a memory leak in expr.

When running:
 expr length "hello"

Output:
=================================================================
==755058==ERROR: LeakSanitizer: detected memory leaks

Direct leak of 24 byte(s) in 1 object(s) allocated from:
    #0 0xffff7f7a2524 in __interceptor_malloc
../../../../libsanitizer/asan/asan_malloc_linux.cpp:69
    #1 0xaaaacd31f4c8 in xmalloc ../lib/xmalloc.c:45
    #2 0xaaaacd2a0dd4 in int_value ../src/expr.c:369
    #3 0xaaaacd2a0dd4 in eval6 ../src/expr.c:714
    #4 0xaaaacd2a0dd4 in eval6 ../src/expr.c:694
    #5 0xaaaacd2a4f44 in eval5 ../src/expr.c:786
    #6 0xaaaacd2a5320 in eval4 ../src/expr.c:817
    #7 0xaaaacd2a595c in eval3 ../src/expr.c:856
    #8 0xaaaacd2a5dbc in eval2 ../src/expr.c:886
    #9 0xaaaacd2a72e0 in eval1 ../src/expr.c:965
    #10 0xaaaacd2a7874 in eval ../src/expr.c:996
    #11 0xaaaacd29d3e0 in main ../src/expr.c:352
lmpx.com only provides a reader for public news (NNTP) servers. It is not affiliated with the servers or forums shown here and is not responsible for the content of articles, which is written by their respective authors.