Commit 4e5e6b45 authored by Tobias Hunger's avatar Tobias Hunger Committed by Orgad Shaneh

Core::Id: Fix possible crash in operator ==

Revert a workaround applied earlier

Change-Id: I825bdf6df662a5509166b9b7d12a4fb305cba6cd
Reviewed-by: Orgad Shaneh's avatarOrgad Shaneh <orgads@gmail.com>
parent 04db5c44
......@@ -89,7 +89,7 @@ public:
static bool operator==(const StringHolder &sh1, const StringHolder &sh2)
{
// sh.n is unlikely to discriminate better than the hash.
return sh1.h == sh2.h && strcmp(sh1.str, sh1.str) == 0;
return sh1.h == sh2.h && sh1.str && sh2.str && strcmp(sh1.str, sh2.str) == 0;
}
......@@ -314,7 +314,11 @@ void Id::registerId(int uid, const char *name)
bool Id::operator==(const char *name) const
{
return strcmp(stringFromId.value(m_id).str, name) == 0;
const char *string = stringFromId.value(m_id).str;
if (string && name)
return strcmp(string, name) == 0;
else
return false;
}
// For debugging purposes
......
......@@ -395,7 +395,7 @@ CustomExecutableRunConfigurationFactory::~CustomExecutableRunConfigurationFactor
bool CustomExecutableRunConfigurationFactory::canCreate(ProjectExplorer::Target *parent,
const Core::Id id) const
{
if (!canHandle(parent) || !id.isValid())
if (!canHandle(parent))
return false;
return id == CUSTOM_EXECUTABLE_ID;
}
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment