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

Revert a workaround applied earlier

Change-Id: I825bdf6df662a5509166b9b7d12a4fb305cba6cd
Reviewed-by: Orgad Shaneh <orgads@gmail.com>
This commit is contained in:
Tobias Hunger
2013-01-23 15:51:52 +01:00
committed by Orgad Shaneh
parent 04db5c4479
commit 4e5e6b45fe
2 changed files with 7 additions and 3 deletions

View File

@@ -89,7 +89,7 @@ public:
static bool operator==(const StringHolder &sh1, const StringHolder &sh2) static bool operator==(const StringHolder &sh1, const StringHolder &sh2)
{ {
// sh.n is unlikely to discriminate better than the hash. // 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 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 // For debugging purposes

View File

@@ -395,7 +395,7 @@ CustomExecutableRunConfigurationFactory::~CustomExecutableRunConfigurationFactor
bool CustomExecutableRunConfigurationFactory::canCreate(ProjectExplorer::Target *parent, bool CustomExecutableRunConfigurationFactory::canCreate(ProjectExplorer::Target *parent,
const Core::Id id) const const Core::Id id) const
{ {
if (!canHandle(parent) || !id.isValid()) if (!canHandle(parent))
return false; return false;
return id == CUSTOM_EXECUTABLE_ID; return id == CUSTOM_EXECUTABLE_ID;
} }