Source-Changes-HG archive
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index][Old Index]
[src/trunk]: src/usr.bin/make make: fix memory leak when evaluating ${.SUFFIX...
details: https://anonhg.NetBSD.org/src/rev/87048041505f
branches: trunk
changeset: 1027601:87048041505f
user: rillig <rillig%NetBSD.org@localhost>
date: Mon Dec 13 00:33:33 2021 +0000
description:
make: fix memory leak when evaluating ${.SUFFIX} (since yesterday)
diffstat:
usr.bin/make/nonints.h | 4 ++--
usr.bin/make/suff.c | 6 +++---
usr.bin/make/var.c | 18 ++++++++----------
3 files changed, 13 insertions(+), 15 deletions(-)
diffs (84 lines):
diff -r c147c17a9c0d -r 87048041505f usr.bin/make/nonints.h
--- a/usr.bin/make/nonints.h Mon Dec 13 00:09:07 2021 +0000
+++ b/usr.bin/make/nonints.h Mon Dec 13 00:33:33 2021 +0000
@@ -1,4 +1,4 @@
-/* $NetBSD: nonints.h,v 1.217 2021/12/12 20:45:48 sjg Exp $ */
+/* $NetBSD: nonints.h,v 1.218 2021/12/13 00:33:33 rillig Exp $ */
/*
* Copyright (c) 1988, 1989, 1990, 1993
@@ -184,7 +184,7 @@
SearchPath *Suff_FindPath(GNode *);
void Suff_SetNull(const char *);
void Suff_PrintAll(void);
-const char *Suff_NamesStr(void);
+char *Suff_NamesStr(void);
/* targ.c */
void Targ_Init(void);
diff -r c147c17a9c0d -r 87048041505f usr.bin/make/suff.c
--- a/usr.bin/make/suff.c Mon Dec 13 00:09:07 2021 +0000
+++ b/usr.bin/make/suff.c Mon Dec 13 00:33:33 2021 +0000
@@ -1,4 +1,4 @@
-/* $NetBSD: suff.c,v 1.357 2021/12/12 20:45:48 sjg Exp $ */
+/* $NetBSD: suff.c,v 1.358 2021/12/13 00:33:33 rillig Exp $ */
/*
* Copyright (c) 1988, 1989, 1990, 1993
@@ -115,7 +115,7 @@
#include "dir.h"
/* "@(#)suff.c 8.4 (Berkeley) 3/21/94" */
-MAKE_RCSID("$NetBSD: suff.c,v 1.357 2021/12/12 20:45:48 sjg Exp $");
+MAKE_RCSID("$NetBSD: suff.c,v 1.358 2021/12/13 00:33:33 rillig Exp $");
typedef List SuffixList;
typedef ListNode SuffixListNode;
@@ -2178,7 +2178,7 @@
}
}
-const char *
+char *
Suff_NamesStr(void)
{
Buffer buf;
diff -r c147c17a9c0d -r 87048041505f usr.bin/make/var.c
--- a/usr.bin/make/var.c Mon Dec 13 00:09:07 2021 +0000
+++ b/usr.bin/make/var.c Mon Dec 13 00:33:33 2021 +0000
@@ -1,4 +1,4 @@
-/* $NetBSD: var.c,v 1.973 2021/12/12 20:45:48 sjg Exp $ */
+/* $NetBSD: var.c,v 1.974 2021/12/13 00:33:33 rillig Exp $ */
/*
* Copyright (c) 1988, 1989, 1990, 1993
@@ -140,7 +140,7 @@
#include "metachar.h"
/* "@(#)var.c 8.3 (Berkeley) 3/19/94" */
-MAKE_RCSID("$NetBSD: var.c,v 1.973 2021/12/12 20:45:48 sjg Exp $");
+MAKE_RCSID("$NetBSD: var.c,v 1.974 2021/12/13 00:33:33 rillig Exp $");
/*
* Variables are defined using one of the VAR=value assignments. Their
@@ -4405,14 +4405,12 @@
/* At this point, p points just after the variable name,
* either at ':' or at endc. */
- if (v == NULL) {
- if (Substring_Equals(name, ".SUFFIXES"))
- v = VarNew(Substring_Str(name),
- Suff_NamesStr(), false, true);
- else
- v = FindLocalLegacyVar(name, scope,
- out_true_extraModifiers);
- }
+ if (v == NULL && Substring_Equals(name, ".SUFFIXES")) {
+ char *suffixes = Suff_NamesStr();
+ v = VarNew(Substring_Str(name), suffixes, false, true);
+ free(suffixes);
+ } else if (v == NULL)
+ v = FindLocalLegacyVar(name, scope, out_true_extraModifiers);
if (v == NULL) {
/*
Home |
Main Index |
Thread Index |
Old Index