[Lldb-commits] [lldb] [LLDB] Make sure FILE* is valid before trying to flush it. (PR #169088)

John Harrison via lldb-commits lldb-commits at lists.llvm.org
Fri Nov 21 12:38:22 PST 2025


================
@@ -378,7 +378,10 @@ Status NativeFile::Close() {
           m_options & (File::eOpenOptionReadOnly | File::eOpenOptionWriteOnly |
                        File::eOpenOptionReadWrite);
 
-      if (rw == eOpenOptionWriteOnly || rw == eOpenOptionReadWrite) {
+      // If the stream is writable, and has not already been closed, flush
+      // it.
+      if ((rw == eOpenOptionWriteOnly || rw == eOpenOptionReadWrite) &&
+          (m_stream->_flags != m_stream->_fileno)) {
----------------
ashgti wrote:

I think maybe https://github.com/llvm/llvm-project/blob/427c18208f73e8d193c4e8f0e05493cb9d2272eb/lldb/unittests/Editline/EditlineTest.cpp#L50 is closing the file handle but somewhere we think we transferred ownership to the NativeFile

https://github.com/llvm/llvm-project/pull/169088


More information about the lldb-commits mailing list