From 772ecb66aa5f92f2ea45212a5bf752a6ce04a1af Mon Sep 17 00:00:00 2001 From: sjg Date: Fri, 28 Jul 2006 17:06:14 +0000 Subject: [PATCH] Fix minor mem leak in PrintOnError(). --- usr.bin/make/main.c | 18 +++++++++++------- 1 file changed, 11 insertions(+), 7 deletions(-) diff --git a/usr.bin/make/main.c b/usr.bin/make/main.c index 834f2e20c582..e007c0f01ae5 100644 --- a/usr.bin/make/main.c +++ b/usr.bin/make/main.c @@ -1,4 +1,4 @@ -/* $NetBSD: main.c,v 1.127 2006/06/29 22:02:06 rillig Exp $ */ +/* $NetBSD: main.c,v 1.128 2006/07/28 17:06:14 sjg Exp $ */ /* * Copyright (c) 1988, 1989, 1990, 1993 @@ -69,7 +69,7 @@ */ #ifndef MAKE_NATIVE -static char rcsid[] = "$NetBSD: main.c,v 1.127 2006/06/29 22:02:06 rillig Exp $"; +static char rcsid[] = "$NetBSD: main.c,v 1.128 2006/07/28 17:06:14 sjg Exp $"; #else #include #ifndef lint @@ -81,7 +81,7 @@ __COPYRIGHT("@(#) Copyright (c) 1988, 1989, 1990, 1993\n\ #if 0 static char sccsid[] = "@(#)main.c 8.3 (Berkeley) 3/19/94"; #else -__RCSID("$NetBSD: main.c,v 1.127 2006/06/29 22:02:06 rillig Exp $"); +__RCSID("$NetBSD: main.c,v 1.128 2006/07/28 17:06:14 sjg Exp $"); #endif #endif /* not lint */ #endif @@ -1726,16 +1726,20 @@ void PrintOnError(const char *s) { char tmp[64]; - + char *cp; + if (s) printf("%s", s); printf("\n%s: stopped in %s\n", progname, curdir); strncpy(tmp, "${MAKE_PRINT_VAR_ON_ERROR:@v@$v='${$v}'\n@}", sizeof(tmp) - 1); - s = Var_Subst(NULL, tmp, VAR_GLOBAL, 0); - if (s && *s) - printf("%s", s); + cp = Var_Subst(NULL, tmp, VAR_GLOBAL, 0); + if (cp) { + if (*cp) + printf("%s", cp); + free(cp); + } } void