Mercurial > gnulib
changeset 17361:8c32877a40e6
copy-file, rpmatch: fix problems found by cppcheck
Reported by Arno Onken in
<http://lists.gnu.org/archive/html/bug-gnulib/2013-03/msg00069.html>.
* lib/rpmatch.c (try): Fix memory leak.
* lib/copy-file.c: Include "ignore-value.h".
(qcopy_file_preserving): Ignore chown value.
* modules/copy-file (Depends-on): Add ignore-value.
author | Paul Eggert <eggert@cs.ucla.edu> |
---|---|
date | Tue, 19 Mar 2013 09:30:58 -0700 |
parents | 6959449c25f6 |
children | 7a2e583edf71 |
files | ChangeLog lib/copy-file.c lib/rpmatch.c modules/copy-file |
diffstat | 4 files changed, 17 insertions(+), 2 deletions(-) [+] |
line wrap: on
line diff
--- a/ChangeLog Sun Jan 27 09:54:55 2013 -0800 +++ b/ChangeLog Tue Mar 19 09:30:58 2013 -0700 @@ -1,3 +1,13 @@ +2013-03-19 Paul Eggert <eggert@cs.ucla.edu> + + copy-file, rpmatch: fix problems found by cppcheck + Reported by Arno Onken in + <http://lists.gnu.org/archive/html/bug-gnulib/2013-03/msg00069.html>. + * lib/rpmatch.c (try): Fix memory leak. + * lib/copy-file.c: Include "ignore-value.h". + (qcopy_file_preserving): Ignore chown value. + * modules/copy-file (Depends-on): Add ignore-value. + 2013-01-27 Jim Meyering <jim@meyering.net> prefix-gnulib-mk: give better diagnostics
--- a/lib/copy-file.c Sun Jan 27 09:54:55 2013 -0800 +++ b/lib/copy-file.c Tue Mar 19 09:30:58 2013 -0700 @@ -37,6 +37,7 @@ #endif #include "error.h" +#include "ignore-value.h" #include "safe-read.h" #include "full-write.h" #include "acl.h" @@ -140,7 +141,7 @@ #if HAVE_CHOWN /* Preserve the owner and group. */ - chown (dest_filename, statbuf.st_uid, statbuf.st_gid); + ignore_value (chown (dest_filename, statbuf.st_uid, statbuf.st_gid)); #endif /* Preserve the access permissions. */
--- a/lib/rpmatch.c Sun Jan 27 09:54:55 2013 -0800 +++ b/lib/rpmatch.c Tue Mar 19 09:30:58 2013 -0700 @@ -110,7 +110,10 @@ return -1; /* Compile the pattern and cache it for future runs. */ if (regcomp (re, safe_pattern, REG_EXTENDED) != 0) - return -1; + { + free (safe_pattern); + return -1; + } *lastp = safe_pattern; }