Browse Source

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.
Rich Felker 14 năm trước cách đây
mục cha
commit
bd67467325
1 tập tin đã thay đổi với 1 bổ sung1 xóa
  1. 1 1
      src/stdio/fclose.c

+ 1 - 1
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);