From 3934a31cfa024edfaa406c3706dc943e59f9049c Mon Sep 17 00:00:00 2001 From: Slava Gurevich Date: Wed, 10 Aug 2022 13:04:26 -0700 Subject: [PATCH] [LLDB][NFC] Reliability fixes for IOHandlerCursesGUI - checking retval of function calls - dead code removal - null dereference fix Differential Revision: https://reviews.llvm.org/D131615 --- lldb/source/Core/IOHandlerCursesGUI.cpp | 26 +++++++++++++------------ 1 file changed, 14 insertions(+), 12 deletions(-) diff --git a/lldb/source/Core/IOHandlerCursesGUI.cpp b/lldb/source/Core/IOHandlerCursesGUI.cpp index f96073ab698c..c37c8106224f 100644 --- a/lldb/source/Core/IOHandlerCursesGUI.cpp +++ b/lldb/source/Core/IOHandlerCursesGUI.cpp @@ -3500,19 +3500,19 @@ public: FileAction action; if (m_standard_input_field->IsSpecified()) { - action.Open(STDIN_FILENO, m_standard_input_field->GetFileSpec(), true, - false); - launch_info.AppendFileAction(action); + if (action.Open(STDIN_FILENO, m_standard_input_field->GetFileSpec(), true, + false)) + launch_info.AppendFileAction(action); } if (m_standard_output_field->IsSpecified()) { - action.Open(STDOUT_FILENO, m_standard_output_field->GetFileSpec(), false, - true); - launch_info.AppendFileAction(action); + if (action.Open(STDOUT_FILENO, m_standard_output_field->GetFileSpec(), + false, true)) + launch_info.AppendFileAction(action); } if (m_standard_error_field->IsSpecified()) { - action.Open(STDERR_FILENO, m_standard_error_field->GetFileSpec(), false, - true); - launch_info.AppendFileAction(action); + if (action.Open(STDERR_FILENO, m_standard_error_field->GetFileSpec(), + false, true)) + launch_info.AppendFileAction(action); } } @@ -6821,7 +6821,7 @@ public: bool set_selected_line_to_pc = false; if (update_location) { - const bool process_alive = process ? process->IsAlive() : false; + const bool process_alive = process->IsAlive(); bool thread_changed = false; if (process_alive) { thread = exe_ctx.GetThreadPtr(); @@ -7209,8 +7209,10 @@ public: window.Printf("%*s", desc_x - window.GetCursorX(), ""); window.MoveCursor(window_width - stop_description_len - 15, line_y); - window.PrintfTruncated(1, "<<< Thread %u: %s ", - thread->GetIndexID(), stop_description); + if (thread) + window.PrintfTruncated(1, "<<< Thread %u: %s ", + thread->GetIndexID(), + stop_description); } } else { window.Printf("%*s", window_width - window.GetCursorX() - 1, "");