From 4e5e6b45feeed9988b65c3a7f9c92c30ed030276 Mon Sep 17 00:00:00 2001
From: Tobias Hunger <tobias.hunger@digia.com>
Date: Wed, 23 Jan 2013 15:51:52 +0100
Subject: [PATCH] Core::Id: Fix possible crash in operator ==

Revert a workaround applied earlier

Change-Id: I825bdf6df662a5509166b9b7d12a4fb305cba6cd
Reviewed-by: Orgad Shaneh <orgads@gmail.com>
---
 src/plugins/coreplugin/id.cpp                             | 8 ++++++--
 .../qtsupport/customexecutablerunconfiguration.cpp        | 2 +-
 2 files changed, 7 insertions(+), 3 deletions(-)

diff --git a/src/plugins/coreplugin/id.cpp b/src/plugins/coreplugin/id.cpp
index 8cfc02ddfda..416df0a7af6 100644
--- a/src/plugins/coreplugin/id.cpp
+++ b/src/plugins/coreplugin/id.cpp
@@ -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
diff --git a/src/plugins/qtsupport/customexecutablerunconfiguration.cpp b/src/plugins/qtsupport/customexecutablerunconfiguration.cpp
index 18880dd1fbb..3a8cd551b81 100644
--- a/src/plugins/qtsupport/customexecutablerunconfiguration.cpp
+++ b/src/plugins/qtsupport/customexecutablerunconfiguration.cpp
@@ -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;
 }
-- 
GitLab