From 05b694028e0537954ea2d5e69774e0c24bf9ab47 Mon Sep 17 00:00:00 2001 From: Rich Felker Date: Mon, 28 Mar 2011 17:31:01 -0400 Subject: [PATCH] fix getc - the classic error of trying to store EOF+0-255 in a char type.. --- src/stdio/__uflow.c | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/src/stdio/__uflow.c b/src/stdio/__uflow.c index 544dda98..e28922c2 100644 --- a/src/stdio/__uflow.c +++ b/src/stdio/__uflow.c @@ -5,7 +5,7 @@ int __uflow(FILE *f) { - unsigned char c = EOF; - if (f->rend || !__toread(f)) f->read(f, &c, 1); - return c; + unsigned char c; + if ((f->rend || !__toread(f)) && f->read(f, &c, 1)==1) return c; + return EOF; } -- 2.25.1