Subject: bug#15978: closed (Re: bug#15978: FYI: patch: maint: minor cleanup: xmalloc+strcpy -> xmemdup)

From: [email-masked] (GNU bug Tracking System)
Date: Wed, 27 Nov 2013 23:56:03 +0000

Your bug report

#15978: FYI: patch: maint: minor cleanup: xmalloc+strcpy -> xmemdup

which was filed against the grep package, has been closed.

The explanation is attached below, along with your original report.
If you require more details, please reply to [email-masked].

-- 
15978: http://debbugs.gnu.org/cgi/bugreport.cgi?bug=15978
GNU Bug Tracking System
Contact [email-masked] with problems

Subject: Re: bug#15978: FYI: patch: maint: minor cleanup: xmalloc+strcpy -> xmemdup
From: Jim Meyering <[email-masked]>
To: [email-masked]
Date: Wed, 27 Nov 2013 15:55:14 -0800
List-Id: <debbugs-submit.debbugs.gnu.org>

pushed

Subject: FYI: patch: maint: minor cleanup: xmalloc+strcpy -> xmemdup
From: Jim Meyering <[email-masked]>
To: [email-masked]
Date: Mon, 25 Nov 2013 17:55:07 -0800
List-Id: <debbugs-submit.debbugs.gnu.org>

From ed3994108bf15f0d7c35d5351d5bc613fa5d70cd Mon Sep 17 00:00:00 2001
From: Jim Meyering <[email-masked]>
Date: Fri, 22 Nov 2013 20:13:53 -0800
Subject: [PATCH] maint: minor cleanup: xmalloc+strcpy -> xmemdup

* src/main.c (main): Replace an xmalloc+strcpy combination
with an equivalent use of xmemdup.
---
 src/main.c | 3 +--
 1 file changed, 1 insertion(+), 2 deletions(-)

diff --git a/src/main.c b/src/main.c
index d9c7759..7ecf00a 100644
--- a/src/main.c
+++ b/src/main.c
@@ -2248,8 +2248,7 @@ main (int argc, char **argv)
     {
       /* A copy must be made in case of an xrealloc() or free() later.  */
       keycc = strlen (argv[optind]);
-      keys = xmalloc (keycc + 1);
-      strcpy (keys, argv[optind++]);
+      keys = xmemdup (argv[optind++], keycc + 1);
     }
   else
     usage (EXIT_TROUBLE);
-- 
1.8.5.rc2.6.gc6f1b92