[Lldb-commits] [lldb] r374197 - protect libedit and LLDB gui from receiving null FILE* streams

Lawrence D'Anna via lldb-commits lldb-commits at lists.llvm.org
Wed Oct 9 11:43:04 PDT 2019


Author: lawrence_danna
Date: Wed Oct  9 11:43:03 2019
New Revision: 374197

URL: http://llvm.org/viewvc/llvm-project?rev=374197&view=rev
Log:
protect libedit and LLDB gui from receiving null FILE* streams

Summary:
We now have valid files that will return NULL from GetStream().
libedit and the LLDB gui are the only places left that need FILE*
streams.  Both are doing curses-like user interaction that only
make sense with a real terminal anyway, so there is no need to convert
them off of their use of FILE*.   But we should check for null streams
before enabling these features.

Reviewers: JDevlieghere, jasonmolenda, labath

Reviewed By: JDevlieghere, labath

Subscribers: lldb-commits

Tags: #lldb

Differential Revision: https://reviews.llvm.org/D68677

Modified:
    lldb/trunk/source/Commands/CommandObjectGUI.cpp
    lldb/trunk/source/Core/IOHandler.cpp

Modified: lldb/trunk/source/Commands/CommandObjectGUI.cpp
URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/source/Commands/CommandObjectGUI.cpp?rev=374197&r1=374196&r2=374197&view=diff
==============================================================================
--- lldb/trunk/source/Commands/CommandObjectGUI.cpp (original)
+++ lldb/trunk/source/Commands/CommandObjectGUI.cpp Wed Oct  9 11:43:03 2019
@@ -29,7 +29,9 @@ bool CommandObjectGUI::DoExecute(Args &a
     Debugger &debugger = GetDebugger();
 
     File &input = debugger.GetInputFile();
-    if (input.GetIsRealTerminal() && input.GetIsInteractive()) {
+    File &output = debugger.GetOutputFile();
+    if (input.GetStream() && output.GetStream() && input.GetIsRealTerminal() &&
+        input.GetIsInteractive()) {
       IOHandlerSP io_handler_sp(new IOHandlerCursesGUI(debugger));
       if (io_handler_sp)
         debugger.PushIOHandler(io_handler_sp);

Modified: lldb/trunk/source/Core/IOHandler.cpp
URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/source/Core/IOHandler.cpp?rev=374197&r1=374196&r2=374197&view=diff
==============================================================================
--- lldb/trunk/source/Core/IOHandler.cpp (original)
+++ lldb/trunk/source/Core/IOHandler.cpp Wed Oct  9 11:43:03 2019
@@ -266,7 +266,8 @@ IOHandlerEditline::IOHandlerEditline(
 #ifndef LLDB_DISABLE_LIBEDIT
   bool use_editline = false;
 
-  use_editline = m_input_sp && m_input_sp->GetIsRealTerminal();
+  use_editline = GetInputFILE() && GetOutputFILE() && GetErrorFILE() &&
+                 m_input_sp && m_input_sp->GetIsRealTerminal();
 
   if (use_editline) {
     m_editline_up.reset(new Editline(editline_name, GetInputFILE(),




More information about the lldb-commits mailing list