in clock_getres, check for null pointer before storing result
[musl] / src / stdio / ungetc.c
index 7f56f8d..180673a 100644 (file)
@@ -6,7 +6,8 @@ int ungetc(int c, FILE *f)
 
        FLOCK(f);
 
-       if ((!f->rend && __toread(f)) || f->rpos <= f->buf - UNGET) {
+       if (!f->rpos) __toread(f);
+       if (!f->rpos || f->rpos <= f->buf - UNGET) {
                FUNLOCK(f);
                return EOF;
        }