Module Name: src
Committed By: msaitoh
Date: Mon Jan 21 03:24:43 UTC 2013
Modified Files:
src/usr.bin/grep: util.c
Log Message:
Fix memory leak in file_matching().
To generate a diff of this commit:
cvs rdiff -u -r1.16 -r1.17 src/usr.bin/grep/util.c
Please note that diffs are not public domain; they are subject to the
copyright notices on the relevant files.
Modified files:
Index: src/usr.bin/grep/util.c
diff -u src/usr.bin/grep/util.c:1.16 src/usr.bin/grep/util.c:1.17
--- src/usr.bin/grep/util.c:1.16 Sun May 6 22:32:05 2012
+++ src/usr.bin/grep/util.c Mon Jan 21 03:24:43 2013
@@ -1,4 +1,4 @@
-/* $NetBSD: util.c,v 1.16 2012/05/06 22:32:05 joerg Exp $ */
+/* $NetBSD: util.c,v 1.17 2013/01/21 03:24:43 msaitoh Exp $ */
/* $FreeBSD: head/usr.bin/grep/util.c 211496 2010-08-19 09:28:59Z des $ */
/* $OpenBSD: util.c,v 1.39 2010/07/02 22:18:03 tedu Exp $ */
@@ -34,7 +34,7 @@
#endif
#include <sys/cdefs.h>
-__RCSID("$NetBSD: util.c,v 1.16 2012/05/06 22:32:05 joerg Exp $");
+__RCSID("$NetBSD: util.c,v 1.17 2013/01/21 03:24:43 msaitoh Exp $");
#include <sys/stat.h>
#include <sys/types.h>
@@ -74,9 +74,10 @@ file_matching(const char *fname)
for (i = 0; i < fpatterns; ++i) {
if (fnmatch(fpattern[i].pat, fname, 0) == 0 ||
fnmatch(fpattern[i].pat, fname_base, 0) == 0) {
- if (fpattern[i].mode == EXCL_PAT)
+ if (fpattern[i].mode == EXCL_PAT) {
+ free(fname_copy);
return (false);
- else
+ } else
ret = true;
}
}