[libc-commits] [PATCH] D119458: [libc] Add a platform independent buffered file IO data structure.

Siva Chandra via Phabricator via libc-commits libc-commits at lists.llvm.org
Mon Feb 14 09:07:51 PST 2022


sivachandra added inline comments.


================
Comment at: libc/src/__support/File/file.cpp:167
+
+int File::close() {
+  {
----------------
lntue wrote:
> Do we need to add a check at the beginning of all other accessing methods to make sure that `close` has not been called?
Couple of things:
1. It is undefined behavior to perform file operations on closed files. So, user code should not try to close an already closed file.
2. The File data structure is not available after a close, which means it is use after free to perform any checking.


Repository:
  rG LLVM Github Monorepo

CHANGES SINCE LAST ACTION
  https://reviews.llvm.org/D119458/new/

https://reviews.llvm.org/D119458



More information about the libc-commits mailing list