fix double-processing of DT_RELR relocations in ldso relocating itself
[musl] / src / stdio / __uflow.c
index 544dda9..2a88bca 100644 (file)
@@ -1,11 +1,11 @@
 #include "stdio_impl.h"
 
-/* This function will never be called if there is already data
- * buffered for reading. Thus we can get by with very few branches. */
+/* This function assumes it will never be called if there is already
+ * data buffered for reading. */
 
 int __uflow(FILE *f)
 {
-       unsigned char c = EOF;
-       if (f->rend || !__toread(f)) f->read(f, &c, 1);
-       return c;
+       unsigned char c;
+       if (!__toread(f) && f->read(f, &c, 1)==1) return c;
+       return EOF;
 }