fix undefined call order in fclose, possible lost output depending on compiler
authorRich Felker <dalias@aerifal.cx>
Mon, 2 May 2011 02:59:14 +0000 (22:59 -0400)
committerRich Felker <dalias@aerifal.cx>
Mon, 2 May 2011 02:59:14 +0000 (22:59 -0400)
pcc turned up this bug by calling f->close(f) before fflush(f),
resulting in lost output and error on flush.

src/stdio/fclose.c

index 26bc37e8c3dbb82a0292f0f67a8b823b56158fc5..9481470de12777352763f15e5c0b5834b832466a 100644 (file)
@@ -13,7 +13,7 @@ int fclose(FILE *f)
                OFLUNLOCK();
        }
 
-       r = fflush(f) | f->close(f);
+       r = -(fflush(f) || f->close(f));
 
        if (!perm) free(f);