Thanks.  The rpmatch.c issue is a true memory leak.

The three regcomp.c issues seem to be false alarms: that code
is not compiled for gnulib and the diagnostics suggest that there
may be a bug in cppcheck.

The copy-file.c issue is not a real bug but I suppose other people
will run into the false alarm so it's worth fixing.

I pushed the attached patch to try to address the two problems caught.
From 946440bdf504f580c8810aaddcab52655f8f3047 Mon Sep 17 00:00:00 2001
From: Paul Eggert <egg...@cs.ucla.edu>
Date: Tue, 19 Mar 2013 09:30:58 -0700
Subject: [PATCH] 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.
---
 ChangeLog         | 10 ++++++++++
 lib/copy-file.c   |  3 ++-
 lib/rpmatch.c     |  5 ++++-
 modules/copy-file |  1 +
 4 files changed, 17 insertions(+), 2 deletions(-)

diff --git a/ChangeLog b/ChangeLog
index 98d74d3..cfa4751 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,3 +1,13 @@
+2013-03-19  Paul Eggert  <egg...@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  <j...@meyering.net>
 
        prefix-gnulib-mk: give better diagnostics
diff --git a/lib/copy-file.c b/lib/copy-file.c
index 0d4dcd6..5660522 100644
--- a/lib/copy-file.c
+++ b/lib/copy-file.c
@@ -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 @@ qcopy_file_preserving (const char *src_filename, const char 
*dest_filename)
 
 #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.  */
diff --git a/lib/rpmatch.c b/lib/rpmatch.c
index cf12523..ccb45f3 100644
--- a/lib/rpmatch.c
+++ b/lib/rpmatch.c
@@ -110,7 +110,10 @@ try (const char *response, const char *pattern, char 
**lastp, regex_t *re)
         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;
     }
 
diff --git a/modules/copy-file b/modules/copy-file
index 1c50d55..2673ff0 100644
--- a/modules/copy-file
+++ b/modules/copy-file
@@ -13,6 +13,7 @@ error
 fstat
 full-write
 gettext-h
+ignore-value
 open
 quote
 safe-read
-- 
1.7.11.7

Reply via email to