Source-Changes-HG archive
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index][Old Index]
[src/trunk]: src/usr.bin/make Plug memory leaks in Dir_FindFile.
details: https://anonhg.NetBSD.org/src/rev/9ff271302047
branches: trunk
changeset: 352987:9ff271302047
user: riastradh <riastradh%NetBSD.org@localhost>
date: Sun Apr 16 21:14:47 2017 +0000
description:
Plug memory leaks in Dir_FindFile.
CID 978364
diffstat:
usr.bin/make/dir.c | 32 ++++++++++++++++++++++++--------
1 files changed, 24 insertions(+), 8 deletions(-)
diffs (70 lines):
diff -r 00600122e04a -r 9ff271302047 usr.bin/make/dir.c
--- a/usr.bin/make/dir.c Sun Apr 16 21:04:44 2017 +0000
+++ b/usr.bin/make/dir.c Sun Apr 16 21:14:47 2017 +0000
@@ -1,4 +1,4 @@
-/* $NetBSD: dir.c,v 1.70 2017/04/16 19:53:58 riastradh Exp $ */
+/* $NetBSD: dir.c,v 1.71 2017/04/16 21:14:47 riastradh Exp $ */
/*
* Copyright (c) 1988, 1989, 1990 The Regents of the University of California.
@@ -70,14 +70,14 @@
*/
#ifndef MAKE_NATIVE
-static char rcsid[] = "$NetBSD: dir.c,v 1.70 2017/04/16 19:53:58 riastradh Exp $";
+static char rcsid[] = "$NetBSD: dir.c,v 1.71 2017/04/16 21:14:47 riastradh Exp $";
#else
#include <sys/cdefs.h>
#ifndef lint
#if 0
static char sccsid[] = "@(#)dir.c 8.2 (Berkeley) 1/2/94";
#else
-__RCSID("$NetBSD: dir.c,v 1.70 2017/04/16 19:53:58 riastradh Exp $");
+__RCSID("$NetBSD: dir.c,v 1.71 2017/04/16 21:14:47 riastradh Exp $");
#endif
#endif /* not lint */
#endif
@@ -1315,8 +1315,14 @@
fprintf(debug_file, " Trying exact path matches...\n");
}
- if (!hasLastDot && cur && (file = DirLookupAbs(cur, name, cp)) != NULL)
- return *file?file:NULL;
+ if (!hasLastDot && cur && ((file = DirLookupAbs(cur, name, cp))
+ != NULL)) {
+ if (file[0] == '\0') {
+ free(file);
+ return NULL;
+ }
+ return file;
+ }
(void)Lst_Open(path);
while ((ln = Lst_Next(path)) != NULL) {
@@ -1325,13 +1331,23 @@
continue;
if ((file = DirLookupAbs(p, name, cp)) != NULL) {
Lst_Close(path);
- return *file?file:NULL;
+ if (file[0] == '\0') {
+ free(file);
+ return NULL;
+ }
+ return file;
}
}
Lst_Close(path);
- if (hasLastDot && cur && (file = DirLookupAbs(cur, name, cp)) != NULL)
- return *file?file:NULL;
+ if (hasLastDot && cur && ((file = DirLookupAbs(cur, name, cp))
+ != NULL)) {
+ if (file[0] == '\0') {
+ free(file);
+ return NULL;
+ }
+ return file;
+ }
}
/*
Home |
Main Index |
Thread Index |
Old Index