dualbus@debian:~/src/gnu/bash$ ./bash --noprofile --norc -ic 'HISTFILE=/dev/null; history -r'
================================================================= ==24289==ERROR: LeakSanitizer: detected memory leaks Direct leak of 10 byte(s) in 1 object(s) allocated from: #0 0x7efe83383d28 in malloc (/usr/lib/x86_64-linux-gnu/libasan.so.3+0xc1d28) #1 0x55a42abc3195 in xmalloc /home/dualbus/src/gnu/bash/xmalloc.c:112 #2 0x55a42ac8b2c2 in history_filename /home/dualbus/src/gnu/bash/lib/readline/histfile.c:152 #3 0x55a42ac8bc5a in read_history_range /home/dualbus/src/gnu/bash/lib/readline/histfile.c:280 #4 0x55a42ac8bb7e in read_history /home/dualbus/src/gnu/bash/lib/readline/histfile.c:253 #5 0x55a42abdd23a in history_builtin history.def:273 #6 0x55a42aafd72b in execute_builtin /home/dualbus/src/gnu/bash/execute_cmd.c:4603 #7 0x55a42aaff341 in execute_builtin_or_function /home/dualbus/src/gnu/bash/execute_cmd.c:5101 #8 0x55a42aafcbc1 in execute_simple_command /home/dualbus/src/gnu/bash/execute_cmd.c:4389 #9 0x55a42aaeaac2 in execute_command_internal /home/dualbus/src/gnu/bash/execute_cmd.c:811 #10 0x55a42aaf33ac in execute_connection /home/dualbus/src/gnu/bash/execute_cmd.c:2637 #11 0x55a42aaeb897 in execute_command_internal /home/dualbus/src/gnu/bash/execute_cmd.c:980 #12 0x55a42abd44ae in parse_and_execute /home/dualbus/src/gnu/bash/builtins/evalstring.c:430 #13 0x55a42aab6121 in run_one_command /home/dualbus/src/gnu/bash/shell.c:1405 #14 0x55a42aab45fa in main /home/dualbus/src/gnu/bash/shell.c:718 #15 0x7efe82b162b0 in __libc_start_main (/lib/x86_64-linux-gnu/libc.so.6+0x202b0) SUMMARY: AddressSanitizer: 10 byte(s) leaked in 1 allocation(s). Fix: dualbus@debian:~/src/gnu/bash$ git diff -- lib/readline/histfile.c diff --git a/lib/readline/histfile.c b/lib/readline/histfile.c index 489801b4..66a76118 100644 --- a/lib/readline/histfile.c +++ b/lib/readline/histfile.c @@ -292,8 +292,10 @@ read_history_range (const char *filename, int from, int to) goto error_and_exit; } - if (file_size == 0) + if (file_size == 0) { + FREE (input); return 0; /* don't waste time if we don't have to */ + } #ifdef HISTORY_USE_MMAP /* We map read/write and private so we can change newlines to NULs without