summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--NEWS2
-rw-r--r--src/uniq.c2
2 files changed, 3 insertions, 1 deletions
diff --git a/NEWS b/NEWS
index 9ccad63a3..3ec35c7bb 100644
--- a/NEWS
+++ b/NEWS
@@ -13,6 +13,8 @@ GNU coreutils NEWS -*- outline -*-
rm -f no longer fails for EINVAL or EILSEQ on file systems that
reject file names invalid for that file system.
+ uniq -f NUM no longer tries to process fields after end of line.
+
* Noteworthy changes in release 8.9 (2011-01-04) [stable]
diff --git a/src/uniq.c b/src/uniq.c
index 7bdbc4f86..9c7e37c7b 100644
--- a/src/uniq.c
+++ b/src/uniq.c
@@ -214,7 +214,7 @@ find_field (struct linebuffer const *line)
size_t size = line->length - 1;
size_t i = 0;
- for (count = 0; count < skip_fields; count++)
+ for (count = 0; count < skip_fields && i < size; count++)
{
while (i < size && isblank (to_uchar (lp[i])))
i++;