[Top][All Lists]
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[Findutils-patches] patch for #20662 memory leak
From: |
Eric Blake |
Subject: |
[Findutils-patches] patch for #20662 memory leak |
Date: |
Thu, 02 Aug 2007 07:06:17 -0600 |
User-agent: |
Mozilla/5.0 (Windows; U; Windows NT 5.1; en-US; rv:1.8.1.5) Gecko/20070716 Thunderbird/2.0.0.5 Mnenhy/0.7.5.666 |
-----BEGIN PGP SIGNED MESSAGE-----
Hash: SHA1
OK to apply to both branch and head? I don't know of a way to make the
testsuite expose memory leaks, so this does not include a testsuite addition.
2007-08-02 Eric Blake <address@hidden>
Fix Savannah bug #20662.
* find/find.c (at_top): Avoid memory leak.
* find/pred.c (do_fprintf, pred_iname, pred_name): Likewise.
* locate/locate.c (visit_basename): Likewise.
* NEWS: Document the change.
- --
Don't work too hard, make some time for fun as well!
Eric Blake address@hidden
-----BEGIN PGP SIGNATURE-----
Version: GnuPG v1.4.5 (Cygwin)
Comment: Public key at home.comcast.net/~ericblake/eblake.gpg
Comment: Using GnuPG with Mozilla - http://enigmail.mozdev.org
iD8DBQFGsdbJ84KuGfSFAYARAtmcAKDZrCOGACE+hAfwDDglyKq8XSPNMgCaAt3f
2zEFbqYAmJJ6AqsuBjPXyjw=
=9Ihf
-----END PGP SIGNATURE-----
Index: NEWS
===================================================================
RCS file: /sources/findutils/findutils/NEWS,v
retrieving revision 1.199
diff -u -p -r1.199 NEWS
--- NEWS 1 Aug 2007 03:39:57 -0000 1.199
+++ NEWS 2 Aug 2007 13:04:16 -0000
@@ -27,6 +27,9 @@ does not follow the POSIX rules of doing
updatedb, frcode and code now complies with the GNU Project's coding
standards.
+#20662: Avoid memory leak in find -name and other places affected by
+gnulib dirname module.
+
** Enhancements
#20594: Allow fine-tuning of the default argument size used by xargs
Index: find/find.c
===================================================================
RCS file: /sources/findutils/findutils/find/find.c,v
retrieving revision 1.122
diff -u -p -r1.122 find.c
--- find/find.c 2 Jul 2007 08:57:58 -0000 1.122
+++ find/find.c 2 Aug 2007 13:04:16 -0000
@@ -1,6 +1,6 @@
/* find -- search for files in a directory hierarchy
Copyright (C) 1990, 91, 92, 93, 94, 2000,
- 2003, 2004, 2005 Free Software Foundation, Inc.
+ 2003, 2004, 2005, 2007 Free Software Foundation, Inc.
This program is free software: you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
@@ -947,9 +947,9 @@ at_top (char *pathname,
struct stat *pstat))
{
int dirchange;
- char *parent_dir = dir_name(pathname);
- char *base = base_name(pathname);
-
+ char *parent_dir = dir_name (pathname);
+ char *base = last_component (pathname);
+
state.curdepth = 0;
state.starting_path_length = strlen (pathname);
Index: find/pred.c
===================================================================
RCS file: /sources/findutils/findutils/find/pred.c,v
retrieving revision 1.104
diff -u -p -r1.104 pred.c
--- find/pred.c 2 Jul 2007 08:25:43 -0000 1.104
+++ find/pred.c 2 Aug 2007 13:04:17 -0000
@@ -741,7 +741,7 @@ do_fprintf(struct format_val *dest,
break;
case 'f': /* base name of path */
/* sanitised */
- checked_print_quoted (dest, segment->text, base_name (pathname));
+ checked_print_quoted (dest, segment->text, last_component (pathname));
break;
case 'F': /* file system type */
/* trusted */
@@ -1160,7 +1160,7 @@ pred_iname (const char *pathname, struct
/* FNM_PERIOD is not used here because POSIX requires that it not be.
* See
http://standards.ieee.org/reading/ieee/interp/1003-2-92_int/pasc-1003.2-126.html
*/
- base = base_name (pathname);
+ base = last_component (pathname);
if (fnmatch (pred_ptr->args.str, base, FNM_CASEFOLD) == 0)
return (true);
return (false);
@@ -1274,7 +1274,7 @@ pred_name (const char *pathname, struct
const char *base;
(void) stat_buf;
- base = base_name (pathname);
+ base = last_component (pathname);
/* FNM_PERIOD is not used here because POSIX requires that it not be.
* See
http://standards.ieee.org/reading/ieee/interp/1003-2-92_int/pasc-1003.2-126.html
Index: locate/locate.c
===================================================================
RCS file: /sources/findutils/findutils/locate/locate.c,v
retrieving revision 1.88
diff -u -p -r1.88 locate.c
--- locate/locate.c 22 Jul 2007 13:08:22 -0000 1.88
+++ locate/locate.c 2 Aug 2007 13:04:17 -0000
@@ -337,7 +337,7 @@ struct process_data
int len;
char *original_filename; /* The current input database entry. */
size_t pathsize; /* Amount allocated for it. */
- char *munged_filename; /* path or base_name(path) */
+ char *munged_filename; /* path or basename(path) */
FILE *fp; /* The pathname database. */
const char *dbfile; /* Its name, or "<stdin>" */
int slocatedb_format; /* Allows us to cope with slocate's format
variant */
@@ -641,7 +641,7 @@ static int
visit_basename(struct process_data *procdata, void *context)
{
(void) context;
- procdata->munged_filename = base_name(procdata->original_filename);
+ procdata->munged_filename = last_component (procdata->original_filename);
return VISIT_CONTINUE;
}
@@ -1929,4 +1929,3 @@ main (int argc, char **argv)
return dolocate(argc, argv, dbfd);
}
-
- [Findutils-patches] patch for #20662 memory leak,
Eric Blake <=