When second expansion is enabled, the record_files function allocates a struct dep for each dependency string that requires expansion. Later, the expand_deps function completes the expansion, parses new prereqs, and frees the dependency string, but it does not free the dependency struct. This results in one leaked struct dep per-rule that requires second expansion.
Sample repro makefile is attached. The leaked memory can be tracked using valgrind. --- src/file.c | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/src/file.c b/src/file.c index c20fcf8..1f9270b 100644 --- a/src/file.c +++ b/src/file.c @@ -634,8 +634,11 @@ expand_deps (struct file *f) continue; } - /* Add newly parsed prerequisites. */ + /* free the original prereq */ next = d->next; + free (d); + + /* Add newly parsed prerequisites. */ *dp = new; for (dp = &new->next, d = new->next; d != 0; dp = &d->next, d = d->next) ; -- 2.20.1
.SECONDEXPANSION: .PHONY: foo bar all: foo PRE := bar foo: $$(PRE) @true
_______________________________________________ Bug-make mailing list Bug-make@gnu.org https://lists.gnu.org/mailman/listinfo/bug-make