summaryrefslogtreecommitdiff
path: root/userland
diff options
context:
space:
mode:
authorAnton Kling <anton@kling.gg>2023-10-29 14:19:14 +0100
committerAnton Kling <anton@kling.gg>2023-10-30 21:49:48 +0100
commitc7a07bf214ef9b3fabc15c8e70f696ede9644c2c (patch)
tree1ce5cf0a6ac22c752717255098ac615c84ad9930 /userland
parent351ab5fbadd933da771a1bd008eff3960360cfc5 (diff)
LibC: Bug fix, make sure to invalidate cache if it skips using it
Since when the cache gets skipped the offset in the file increases far outside of the reach of the current cache. Therefore the current cache should be discarded.
Diffstat (limited to 'userland')
-rw-r--r--userland/libc/stdio/stdin.c7
1 files changed, 6 insertions, 1 deletions
diff --git a/userland/libc/stdio/stdin.c b/userland/libc/stdio/stdin.c
index 98189e2..2ced1a0 100644
--- a/userland/libc/stdio/stdin.c
+++ b/userland/libc/stdio/stdin.c
@@ -31,7 +31,12 @@ size_t read_fd(FILE *f, unsigned char *s, size_t l) {
// equal to the cache block size. This avoids doing a bunch of extra
// syscalls
if (l >= 4096) {
- return non_cache_read_fd(f, s, l);
+ // Invalidate the cache
+f->read_buffer_stored = 0;
+
+ size_t rc = non_cache_read_fd(f, s, l);
+ f->offset_in_file += rc;
+ return rc;
}
if (!f->read_buffer) {