Source-Changes-HG archive

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index][Old Index]

[src/trunk]: src/usr.bin/grep Fix memory leak in file_matching().



details:   https://anonhg.NetBSD.org/src/rev/d24b8fa695a6
branches:  trunk
changeset: 784178:d24b8fa695a6
user:      msaitoh <msaitoh%NetBSD.org@localhost>
date:      Mon Jan 21 03:24:43 2013 +0000

description:
Fix memory leak in  file_matching().

diffstat:

 usr.bin/grep/util.c |  9 +++++----
 1 files changed, 5 insertions(+), 4 deletions(-)

diffs (31 lines):

diff -r acffa7cd10c5 -r d24b8fa695a6 usr.bin/grep/util.c
--- a/usr.bin/grep/util.c       Mon Jan 21 00:02:11 2013 +0000
+++ b/usr.bin/grep/util.c       Mon Jan 21 03:24:43 2013 +0000
@@ -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 @@
        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;
                }
        }



Home | Main Index | Thread Index | Old Index