Source-Changes-HG archive
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index][Old Index]
[src/trunk]: src/usr.bin/make fix memory leak, simplify
details: https://anonhg.NetBSD.org/src/rev/b2f7ea8cbe6c
branches: trunk
changeset: 345753:b2f7ea8cbe6c
user: christos <christos%NetBSD.org@localhost>
date: Tue Jun 07 03:04:45 2016 +0000
description:
fix memory leak, simplify
diffstat:
usr.bin/make/main.c | 30 +++++++++++-------------------
1 files changed, 11 insertions(+), 19 deletions(-)
diffs (59 lines):
diff -r 65a912584d18 -r b2f7ea8cbe6c usr.bin/make/main.c
--- a/usr.bin/make/main.c Tue Jun 07 01:07:11 2016 +0000
+++ b/usr.bin/make/main.c Tue Jun 07 03:04:45 2016 +0000
@@ -1,4 +1,4 @@
-/* $NetBSD: main.c,v 1.247 2016/06/05 01:39:17 christos Exp $ */
+/* $NetBSD: main.c,v 1.248 2016/06/07 03:04:45 christos Exp $ */
/*
* Copyright (c) 1988, 1989, 1990, 1993
@@ -69,7 +69,7 @@
*/
#ifndef MAKE_NATIVE
-static char rcsid[] = "$NetBSD: main.c,v 1.247 2016/06/05 01:39:17 christos Exp $";
+static char rcsid[] = "$NetBSD: main.c,v 1.248 2016/06/07 03:04:45 christos Exp $";
#else
#include <sys/cdefs.h>
#ifndef lint
@@ -81,7 +81,7 @@
#if 0
static char sccsid[] = "@(#)main.c 8.3 (Berkeley) 3/19/94";
#else
-__RCSID("$NetBSD: main.c,v 1.247 2016/06/05 01:39:17 christos Exp $");
+__RCSID("$NetBSD: main.c,v 1.248 2016/06/07 03:04:45 christos Exp $");
#endif
#endif /* not lint */
#endif
@@ -1869,23 +1869,15 @@
#endif
}
- rp = Var_Value(pathname, cache, &cp);
- if (rp) {
+ if ((rp = Var_Value(pathname, cache, &cp)) != NULL) {
/* a hit */
- if (resolved) {
-#if defined(MAKE_NATIVE) || defined(HAVE_STRLCPY)
- strlcpy(resolved, rp, MAXPATHLEN);
-#else
- strncpy(resolved, rp, MAXPATHLEN);
- resolved[MAXPATHLEN - 1] = '\0';
-#endif
- } else
- resolved = bmake_strdup(rp);
- } else {
- if ((rp = realpath(pathname, resolved))) {
- Var_Set(pathname, rp, cache, 0);
- }
- }
+ strncpy(resolved, rp, MAXPATHLEN);
+ resolved[MAXPATHLEN - 1] = '\0';
+ } else if ((rp = realpath(pathname, resolved)) != NULL) {
+ Var_Set(pathname, rp, cache, 0);
+ } /* else should we negative-cache? */
+
+ free(cp);
return rp ? resolved : NULL;
}
Home |
Main Index |
Thread Index |
Old Index