fgetwc may clobber errno when the result is not WEOF
authorSzabolcs Nagy <nsz@port70.net>
Wed, 10 Jan 2018 21:55:53 +0000 (21:55 +0000)
committerSzabolcs Nagy <nsz@port70.net>
Wed, 10 Jan 2018 21:55:53 +0000 (21:55 +0000)
src/regression/fgetwc-buffering.c

index a73ad54..dc0a13d 100644 (file)
@@ -23,11 +23,11 @@ int main()
        A(write(p[1], "\200", 1) == 1);
        close(p[1]);
 
-       errno = 0;
        wc = fgetwc(stdin);
        if (wc != 0x800)
                t_error("wanted 0x800, got 0x%x\n", (unsigned)wc);
 
+       errno = 0;
        wc = fgetwc(stdin);
        if (wc != WEOF)
                t_error("wanted WEOF, got 0x%x\n", (unsigned)wc);