소스 검색

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 년 전
부모
커밋
bd67467325
1개의 변경된 파일1개의 추가작업 그리고 1개의 파일을 삭제
  1. 1 1
      src/stdio/fclose.c

+ 1 - 1
src/stdio/fclose.c

@@ -13,7 +13,7 @@ int fclose(FILE *f)
 		OFLUNLOCK();
 		OFLUNLOCK();
 	}
 	}
 
 
-	r = fflush(f) | f->close(f);
+	r = -(fflush(f) || f->close(f));
 
 
 	if (!perm) free(f);
 	if (!perm) free(f);