summaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authorPaul Eggert <eggert@cs.ucla.edu>2010-07-26 20:51:02 -0700
committerPaul Eggert <eggert@cs.ucla.edu>2010-07-26 20:51:19 -0700
commitc8d3838681de7137a3eb1127c4c4486023bd2f00 (patch)
tree804105c6f18691d194ac55f419fb95d5216877fd /src
parent247e2396980f659ff126f338e56f54baac1e3717 (diff)
downloadcoreutils-c8d3838681de7137a3eb1127c4c4486023bd2f00.tar.xz
sort: fix bug with EOF at buffer refill
* src/sort.c (fillbuf): Don't append eol unless the line is nonempty. This fixes a bug that was partly but not completely fixed by the aadc67dfdb47f28bb8d1fa5e0fe0f52e2a8c51bf commit (dated July 15). * tests/misc/sort (realloc-buf-2): New test, which catches this bug on 64-bit hosts.
Diffstat (limited to 'src')
-rw-r--r--src/sort.c2
1 files changed, 1 insertions, 1 deletions
diff --git a/src/sort.c b/src/sort.c
index 2ee5a1d4f..588bae80f 100644
--- a/src/sort.c
+++ b/src/sort.c
@@ -1727,7 +1727,7 @@ fillbuf (struct buffer *buf, FILE *fp, char const *file)
buf->eof = true;
if (buf->buf == ptrlim)
return false;
- if (ptrlim[-1] != eol)
+ if (line_start != ptrlim && ptrlim[-1] != eol)
*ptrlim++ = eol;
}
}