On Sat, 30 Dec 2017 18:27:30 +0100 Andreas Schwab <sch...@linux-m68k.org> wrote:
> On Dez 30 2017, Daniel van Gerpen <dan...@vangerpen.de> wrote: > > > When the responsefile's contents are interpolated into the argument > > vector, the pointer to original option string ("@filename") became > > lost. This caused a small leak for every responsefile on the > > commandline. > > argv elements generally don't point to the heap. No, but expandargv() copies argv to the heap and then inserts the contents of the responsefile. The libiberty testsuite uses "@test-expandargv-0.lst" as an argument: valgrind --leak-check=full testsuite/test-expandargv ==15851== Memcheck, a memory error detector ==15851== Copyright (C) 2002-2015, and GNU GPL'd, by Julian Seward et al. ==15851== Using Valgrind-3.12.0 and LibVEX; rerun with -h for copyright info ==15851== Command: testsuite/test-expandargv ==15851== PASS: test-expandargv-0. PASS: test-expandargv-1. PASS: test-expandargv-2. PASS: test-expandargv-3. PASS: test-expandargv-4. PASS: test-expandargv-5. PASS: test-expandargv-6. ==15851== ==15851== HEAP SUMMARY: ==15851== in use at exit: 602 bytes in 28 blocks ==15851== total heap usage: 145 allocs, 117 frees, 931,880 bytes allocated ==15851== ==15851== 23 bytes in 1 blocks are definitely lost in loss record 1 of 4 ==15851== at 0x4C2DB2F: malloc (in /usr/lib/valgrind/vgpreload_memcheck-amd64-linux.so) ==15851== by 0x10A037: xmalloc (xmalloc.c:147) ==15851== by 0x10A0F9: xstrdup (xstrdup.c:34) ==15851== by 0x1097C4: dupargv (argv.c:86) ==15851== by 0x109DBA: expandargv (argv.c:453) ==15851== by 0x109630: run_tests (test-expandargv.c:275) ==15851== by 0x10916F: main (test-expandargv.c:328) [...] Daniel