From e00af8093c2fc454dc3d2f1987e16c5fc64ed8e8 Mon Sep 17 00:00:00 2001 From: Enrico Granata Date: Mon, 1 Oct 2012 17:19:37 +0000 Subject: [PATCH] Fixing a crasher with adding a regex command, due to accessing a shared pointer without first checking for NULL llvm-svn: 164950 --- lldb/source/Interpreter/CommandInterpreter.cpp | 10 ++++------ 1 file changed, 4 insertions(+), 6 deletions(-) diff --git a/lldb/source/Interpreter/CommandInterpreter.cpp b/lldb/source/Interpreter/CommandInterpreter.cpp index eed4038..44ba511 100644 --- a/lldb/source/Interpreter/CommandInterpreter.cpp +++ b/lldb/source/Interpreter/CommandInterpreter.cpp @@ -624,12 +624,10 @@ CommandInterpreter::AddCommand (const char *name, const lldb::CommandObjectSP &c if (name && name[0]) { std::string name_sstr(name); - if (!can_replace) - { - if (m_command_dict.find (name_sstr) != m_command_dict.end()) - return false; - } - if (m_command_dict[name_sstr]->IsRemovable() == false) + bool found = (m_command_dict.find (name_sstr) != m_command_dict.end()); + if (found && !can_replace) + return false; + if (found && m_command_dict[name_sstr]->IsRemovable() == false) return false; m_command_dict[name_sstr] = cmd_sp; return true; -- 2.7.4