llvm-project
c72f8510 - [libc] Fix File::close() cleanup and static stream ownership (#247399)

Commit
18 hours ago
[libc] Fix File::close() cleanup and static stream ownership (#247399) In File::close (1) always reset buffer state and detach any owned buffer before releasing the lock; (2) unlink the stream from File::list_all before freeing the detached buffer, eliminating the use-after-free race with concurrent fflush(nullptr); (3) remove redundant per-backend File::remove_file() calls; (4) always release resources even when flushing buffered writes fails, reporting EIO on short writes. Add a 1-bit own_file flag in File, mark static stdin/stdout/stderr instances on Linux as false so closing them does not delete static storage, and reset LinuxFile::fd to -1 before returning. Assisted-by: LLM
Author
Parents
Loading