summaryrefslogtreecommitdiff
path: root/file_io/unix/seek.c
diff options
context:
space:
mode:
authorPeter Wemm <peter@FreeBSD.org>2018-10-08 08:24:14 +0000
committerPeter Wemm <peter@FreeBSD.org>2018-10-08 08:24:14 +0000
commitf7eb533f85d0941dbf6edb3081f065e4c010b8cc (patch)
treea9a3ba945deee0800d3818a48c45323608935019 /file_io/unix/seek.c
parentdf84d2567179e9d8867957c089683d753016bd75 (diff)
Diffstat (limited to 'file_io/unix/seek.c')
-rw-r--r--file_io/unix/seek.c7
1 files changed, 7 insertions, 0 deletions
diff --git a/file_io/unix/seek.c b/file_io/unix/seek.c
index 3f5aa00e95677..2e973377bf84d 100644
--- a/file_io/unix/seek.c
+++ b/file_io/unix/seek.c
@@ -117,6 +117,13 @@ apr_status_t apr_file_trunc(apr_file_t *fp, apr_off_t offset)
/* Reset buffer positions for write mode */
fp->bufpos = fp->direction = fp->dataRead = 0;
}
+ else if (fp->direction == 0) {
+ /* Discard the read buffer, as we are about to reposition
+ * ourselves to the end of file.
+ */
+ fp->bufpos = 0;
+ fp->dataRead = 0;
+ }
file_unlock(fp);
if (rc) {
return rc;