about summary refs log tree commit diff
path: root/src/stdio/fclose.c
diff options
context:
space:
mode:
authorRich Felker <dalias@aerifal.cx>2011-05-01 22:59:14 -0400
committerRich Felker <dalias@aerifal.cx>2011-05-01 22:59:14 -0400
commitbd6746732536fdf2ebaadff6f98aee0879b1674d (patch)
treeb9d9898f3ed515416bed535aa74180933818d31f /src/stdio/fclose.c
parenta9be201cc0a2c04f430c029dd070fc0fbcd164b3 (diff)
downloadmusl-bd6746732536fdf2ebaadff6f98aee0879b1674d.tar.gz
musl-bd6746732536fdf2ebaadff6f98aee0879b1674d.tar.xz
musl-bd6746732536fdf2ebaadff6f98aee0879b1674d.zip
fix undefined call order in fclose, possible lost output depending on compiler
pcc turned up this bug by calling f->close(f) before fflush(f),
resulting in lost output and error on flush.
Diffstat (limited to 'src/stdio/fclose.c')
-rw-r--r--src/stdio/fclose.c2
1 files changed, 1 insertions, 1 deletions
diff --git a/src/stdio/fclose.c b/src/stdio/fclose.c
index 26bc37e8..9481470d 100644
--- a/src/stdio/fclose.c
+++ b/src/stdio/fclose.c
@@ -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);