Fix minor mem leak in PrintOnError().

This commit is contained in:
sjg 2006-07-28 17:06:14 +00:00
parent bce72f7b6a
commit 772ecb66aa
1 changed files with 11 additions and 7 deletions

View File

@ -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 <sys/cdefs.h>
#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