Commit d165aa8
committed
fix memory leak of MMacro::iname
When running with -fsanitize=leak enabled nasm prints this error:
Direct leak of 25 byte(s) in 5 object(s) allocated from:
#0 0x7f5fc494b867 in __interceptor_malloc ../../../../src/libsanitizer/asan/asan_malloc_linux.cpp:145
#1 0x55a8037f10e0 in nasm_malloc nasmlib/alloc.c:55
#2 0x55a8037f10e0 in nasm_strdup nasmlib/alloc.c:117
#3 0x55a803873172 in expand_mmacro asm/preproc.c:6905
#4 0x55a803873172 in pp_tokline asm/preproc.c:7814
#5 0x55a803873172 in pp_getline asm/preproc.c:7826
#6 0x55a8037eb5d8 in assemble_file asm/nasm.c:1722
#7 0x55a8037e5761 in main asm/nasm.c:719
#8 0x7f5fc4063d8f in __libc_start_call_main ../sysdeps/nptl/libc_start_call_main.h:58
#9 0x7f5fc4063e3f in __libc_start_main_impl ../csu/libc-start.c:392
#10 0x55a8037e7c34 in _start (/home/ivan/d/nasm/nasm+0x2e5c34)
This is reproducible on many tests, for example on zerobyte.asm.
The problem was that MMacro::iname is only allocated but never freed.
Signed-off-by: Ivan Sorokin <vanyacpp@gmail.com>1 parent 396295f commit d165aa8
1 file changed
+4
-0
lines changed| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
986 | 986 | | |
987 | 987 | | |
988 | 988 | | |
| 989 | + | |
989 | 990 | | |
990 | 991 | | |
991 | 992 | | |
| |||
6899 | 6900 | | |
6900 | 6901 | | |
6901 | 6902 | | |
| 6903 | + | |
6902 | 6904 | | |
6903 | 6905 | | |
6904 | 6906 | | |
| |||
7642 | 7644 | | |
7643 | 7645 | | |
7644 | 7646 | | |
| 7647 | + | |
7645 | 7648 | | |
7646 | 7649 | | |
7647 | 7650 | | |
7648 | 7651 | | |
| 7652 | + | |
7649 | 7653 | | |
7650 | 7654 | | |
7651 | 7655 | | |
| |||
0 commit comments