summaryrefslogtreecommitdiff
path: root/src/cut.c
diff options
context:
space:
mode:
authorJim Meyering <jim@meyering.net>2006-12-20 14:25:55 +0100
committerJim Meyering <jim@meyering.net>2006-12-20 14:25:55 +0100
commitd69fc66d81c7166fe689418f42b7cb900d2a1433 (patch)
treed5892567bd10b245328d8da36bef287a0d1ede41 /src/cut.c
parent4e48b4ce334cb601dbbe2562e3aa410dc3ef3fba (diff)
downloadcoreutils-d69fc66d81c7166fe689418f42b7cb900d2a1433.tar.xz
"cut -f 2- A B" no longer triggers a double-free bug
* src/cut.c (cut_fields): Set file-scoped global to NULL after freeing it. This avoids a double-free (and core dump on some systems) for this usage: "echo 1>a; echo 2>b; cut -f2- a b". Reported by James Hunt in <http://bugzilla.redhat.com/220312>. * NEWS: List this bug fix. * THANKS: Mention him. * tests/misc/cut: New file. * tests/misc/Makefile.am (TESTS): Add cut.
Diffstat (limited to 'src/cut.c')
-rw-r--r--src/cut.c1
1 files changed, 1 insertions, 0 deletions
diff --git a/src/cut.c b/src/cut.c
index 73277faa3..c9b83595a 100644
--- a/src/cut.c
+++ b/src/cut.c
@@ -606,6 +606,7 @@ cut_fields (FILE *stream)
if (len < 0)
{
free (field_1_buffer);
+ field_1_buffer = NULL;
if (ferror (stream) || feof (stream))
break;
xalloc_die ();