Source-Changes archive
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index][Old Index]
CVS commit: src/usr.bin/make
Module Name: src
Committed By: rillig
Date: Tue Dec 28 21:56:13 UTC 2021
Modified Files:
src/usr.bin/make: main.c
Log Message:
make: fix double-free in CLEANUP mode (since 2021.12.27.23.11.55)
When make is run without the '-f' option, it searches for the files
'makefile' and 'Makefile' in the current directory. The function
ReadFirstDefaultMakefile allocated memory for these filenames, added the
filenames to opts.makefiles and then freed the memory. From that
moment, opts.makefiles contained dangling pointers.
The function main_CleanUp cleans the list, but only if make is compiled
with -DCLEANUP. Since main.c 1.557 from 2021.12.27.23.11.55, the
strings in opts.makefiles are freed as well, before that, only the list
nodes were freed. Freeing the strings led to the double-free.
Fix this bug by using a separate list for these short-lived strings. At
the point where ReadFirstDefaultMakefile is called, opts.makefiles is
not used anymore, therefore there are no side effects.
To reproduce, run 'make test-coverage', which compiles with -DCLEANUP.
The test opt-chdir failed with a segmentation fault in main_Cleanup.
This test may be the only one that doesn't use the option '-f'.
To generate a diff of this commit:
cvs rdiff -u -r1.561 -r1.562 src/usr.bin/make/main.c
Please note that diffs are not public domain; they are subject to the
copyright notices on the relevant files.
Home |
Main Index |
Thread Index |
Old Index