summaryrefslogtreecommitdiff
path: root/src/grep.c
diff options
context:
space:
mode:
Diffstat (limited to 'src/grep.c')
-rw-r--r--src/grep.c16
1 files changed, 5 insertions, 11 deletions
diff --git a/src/grep.c b/src/grep.c
index f86bce55..271b6b98 100644
--- a/src/grep.c
+++ b/src/grep.c
@@ -943,15 +943,8 @@ fillbuf (size_t save, struct stat const *st)
char *readbuf;
size_t readsize;
- /* Offset from start of buffer to start of old stuff
- that we want to save. */
- size_t saved_offset = buflim - save - buffer;
-
if (pagesize <= buffer + bufalloc - sizeof (uword) - buflim)
- {
- readbuf = buflim;
- bufbeg = buflim - save;
- }
+ readbuf = buflim;
else
{
size_t minsize = save + pagesize;
@@ -989,9 +982,8 @@ fillbuf (size_t save, struct stat const *st)
newbuf = bufalloc < newalloc ? xmalloc (bufalloc = newalloc) : buffer;
readbuf = ALIGN_TO (newbuf + 1 + save, pagesize);
- bufbeg = readbuf - save;
- memmove (bufbeg, buffer + saved_offset, save);
- bufbeg[-1] = eolbyte;
+ size_t moved = save + 1; /* Move the preceding byte sentinel too. */
+ memmove (readbuf - moved, buflim - moved, moved);
if (newbuf != buffer)
{
free (buffer);
@@ -999,6 +991,8 @@ fillbuf (size_t save, struct stat const *st)
}
}
+ bufbeg = readbuf - save;
+
clear_asan_poison ();
readsize = buffer + bufalloc - sizeof (uword) - readbuf;