summaryrefslogtreecommitdiff
path: root/src/cut.c
diff options
context:
space:
mode:
authorCojocaru Alexandru <xojoc@gmx.com>2013-05-07 13:01:46 +0100
committerPádraig Brady <P@draigBrady.com>2013-05-07 13:07:02 +0100
commitb54b47f954c9b97bdb2dbbf51ead908ccb3a4f13 (patch)
tree1c2f45856aef15025b1a8ba5383207f975260aab /src/cut.c
parent7fbe8f46867aa7539799d981c28bdbd28d3a7dd0 (diff)
downloadcoreutils-b54b47f954c9b97bdb2dbbf51ead908ccb3a4f13.tar.xz
cut: fix handling of overlapping ranges
This issue was introduced in commit v8.21-43-g3e466ad * src/cut.c (set_fields): Process all range pairs when merging. * tests/misc/cut-huge-range.sh: Add a test for this edge case. Also fix an issue where we could miss reported errors due to truncation of the 'err' file.
Diffstat (limited to 'src/cut.c')
-rw-r--r--src/cut.c6
1 files changed, 3 insertions, 3 deletions
diff --git a/src/cut.c b/src/cut.c
index b347b307b..9501b3aa7 100644
--- a/src/cut.c
+++ b/src/cut.c
@@ -496,9 +496,9 @@ set_fields (const char *fieldstr)
if (rp[j].lo <= rp[i].hi)
{
rp[i].hi = MAX (rp[j].hi, rp[i].hi);
- memmove (rp + j, rp + j + 1,
- (n_rp - j - 1) * sizeof (struct range_pair));
- --n_rp;
+ memmove (rp + j, rp + j + 1, (n_rp - j - 1) * sizeof *rp);
+ n_rp--;
+ j--;
}
else
break;