Bug 1217047 - try harder in IsContractIDRegistered to return a reasonable answer; r=bsmedberg,f=yury a=lizzard
authorNathan Froyd <froydnj@mozilla.com>
Tue, 20 Oct 2015 15:06:42 -0400
changeset 296748 c66289e84c50
parent 296747 d35d09b0b24f
child 296749 e4802c73f705
push id5316
push userkwierso@gmail.com
push date2015-11-16 20:42 +0000
treeherdermozilla-beta@c66289e84c50 [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
reviewersbsmedberg, lizzard
bugs1217047
milestone43.0
Bug 1217047 - try harder in IsContractIDRegistered to return a reasonable answer; r=bsmedberg,f=yury a=lizzard
xpcom/components/nsComponentManager.cpp
--- a/xpcom/components/nsComponentManager.cpp
+++ b/xpcom/components/nsComponentManager.cpp
@@ -1747,17 +1747,22 @@ nsComponentManagerImpl::IsContractIDRegi
 {
   if (NS_WARN_IF(!aClass)) {
     return NS_ERROR_INVALID_ARG;
   }
 
   nsFactoryEntry* entry = GetFactoryEntry(aClass, strlen(aClass));
 
   if (entry) {
-    *aResult = true;
+    // UnregisterFactory might have left a stale nsFactoryEntry in
+    // mContractIDs, so we should check to see whether this entry has
+    // anything useful.
+    *aResult = (bool(entry->mModule) ||
+                bool(entry->mFactory) ||
+                bool(entry->mServiceObject));
   } else {
     *aResult = false;
   }
   return NS_OK;
 }
 
 NS_IMETHODIMP
 nsComponentManagerImpl::EnumerateCIDs(nsISimpleEnumerator** aEnumerator)