<rdar://problem/12406088> Fixing a crasher with adding a regex command, due to accessing a shared pointer without first checking for NULL
git-svn-id: https://llvm.org/svn/llvm-project/lldb/trunk@164950 91177308-0d34-0410-b5e6-96231b3b80d8
diff --git a/source/Interpreter/CommandInterpreter.cpp b/source/Interpreter/CommandInterpreter.cpp
index eed4038..44ba511 100644
--- a/source/Interpreter/CommandInterpreter.cpp
+++ b/source/Interpreter/CommandInterpreter.cpp
@@ -624,12 +624,10 @@
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;