fix incorrect initial count in shgetc when data is already buffered
[musl] / src / internal / shgetc.c
index 7c4e58c..82e3a4f 100644 (file)
@@ -3,7 +3,7 @@
 void __shlim(FILE *f, off_t lim)
 {
        f->shlim = lim;
-       f->shcnt = f->rend ? f->rend - f->buf : 0;
+       f->shcnt = f->rend - f->rpos;
        if (lim && f->rend - f->rpos > lim)
                f->shend = f->rpos + lim;
        else