Bug 1079311 - Unlock mutex before logging error in RegisterContractIDLocked. r=bsmedberg
--- a/xpcom/components/nsComponentManager.cpp
+++ b/xpcom/components/nsComponentManager.cpp
@@ -558,21 +558,22 @@ nsComponentManagerImpl::RegisterContract
mLock.AssertCurrentThreadOwns();
if (!ProcessSelectorMatches(aEntry->processSelector)) {
return;
}
nsFactoryEntry* f = mFactories.Get(*aEntry->cid);
if (!f) {
- NS_ERROR("No CID found when attempting to map contract ID");
+ NS_WARNING("No CID found when attempting to map contract ID");
char idstr[NSID_LENGTH];
aEntry->cid->ToProvidedString(idstr);
+ SafeMutexAutoUnlock unlock(mLock);
LogMessage("Could not map contract ID '%s' to CID %s because no implementation of the CID is registered.",
aEntry->contractid,
idstr);
return;
}
mContractIDs.Put(nsDependentCString(aEntry->contractid), f);
--- a/xpcom/tests/component/TestComponent.cpp
+++ b/xpcom/tests/component/TestComponent.cpp
@@ -3,31 +3,41 @@
* License, v. 2.0. If a copy of the MPL was not distributed with this
* file, You can obtain one at http://mozilla.org/MPL/2.0/. */
#include "mozilla/ModuleUtils.h"
#define NS_TESTING_CID \
{ 0x335fb596, 0xe52d, 0x418f, \
{ 0xb0, 0x1c, 0x1b, 0xf1, 0x6c, 0xe5, 0xe7, 0xe4 } }
+#define NS_NONEXISTENT_CID \
+{ 0x1e61fb15, 0xead4, 0x45cd, \
+ { 0x80, 0x13, 0x40, 0x99, 0xa7, 0x10, 0xa2, 0xfa } }
NS_DEFINE_NAMED_CID(NS_TESTING_CID);
+NS_DEFINE_NAMED_CID(NS_NONEXISTENT_CID);
static nsresult
DummyConstructorFunc(nsISupports* aOuter, const nsIID& aIID, void** aResult)
{
return NS_ERROR_NOT_IMPLEMENTED;
}
static const mozilla::Module::CIDEntry kTestCIDs[] = {
{ &kNS_TESTING_CID, false, nullptr, DummyConstructorFunc },
{ &kNS_TESTING_CID, false, nullptr, DummyConstructorFunc },
{ nullptr }
};
+static const mozilla::Module::ContractIDEntry kTestContractIDs[] = {
+ { "@testing/foo", &kNS_NONEXISTENT_CID },
+ { nullptr }
+};
+
static const mozilla::Module kTestModule = {
mozilla::Module::kVersion,
- kTestCIDs
+ kTestCIDs,
+ kTestContractIDs
};
NSMODULE_DEFN(dummy) = &kTestModule;