summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorJim Meyering <jim@meyering.net>2006-11-13 19:15:43 +0100
committerJim Meyering <jim@meyering.net>2006-11-13 19:15:43 +0100
commit7932d2e2d47f5a0543b7ee46a4a6ac76037219c0 (patch)
treed3a2fc05af7d1cdf6d664093f5241a0e29f6b347
parent2061f0484753bb8de0fb9dd5821ee983ceda2e23 (diff)
downloadcoreutils-7932d2e2d47f5a0543b7ee46a4a6ac76037219c0.tar.xz
* src/sort.c (insertkey): Use xmemdup, rather than xmalloc+assignment.
From Paul Eggert.
-rw-r--r--ChangeLog3
-rw-r--r--src/sort.c3
2 files changed, 4 insertions, 2 deletions
diff --git a/ChangeLog b/ChangeLog
index e737ee173..c4e225296 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,5 +1,8 @@
2006-11-13 Jim Meyering <jim@meyering.net>
+ * src/sort.c (insertkey): Use xmemdup, rather than xmalloc+assignment.
+ From Paul Eggert.
+
Plug another technically-unimportant leak in sort.
* src/sort.c (main): Don't allocate memory for each new key here.
(insertkey): Allocate memory for each key here, instead.
diff --git a/src/sort.c b/src/sort.c
index bdaf032a3..feaf5a5bc 100644
--- a/src/sort.c
+++ b/src/sort.c
@@ -2105,9 +2105,8 @@ static void
insertkey (struct keyfield *key_arg)
{
struct keyfield **p;
- struct keyfield *key = xmalloc (sizeof *key);
+ struct keyfield *key = xmemdup (key_arg, sizeof *key);
- *key = *key_arg;
for (p = &keylist; *p; p = &(*p)->next)
continue;
*p = key;