Bug 1217047 - try harder in IsContractIDRegistered to return a reasonable answer; r=bsmedberg,f=yury
authorNathan Froyd <froydnj@mozilla.com>
Tue, 20 Oct 2015 15:06:42 -0400
changeset 308654 d34f0bd09295241efba3c390e0b0c1b612984f41
parent 308653 f3ab1f50450af2a5380be725373ba4672326f401
child 308655 89f3fe7202921aaf81b78cc1287b5e99940dc85b
push id7513
push useratolfsen@mozilla.com
push dateFri, 13 Nov 2015 14:03:43 +0000
reviewersbsmedberg
bugs1217047
milestone45.0a1
Bug 1217047 - try harder in IsContractIDRegistered to return a reasonable answer; r=bsmedberg,f=yury
xpcom/components/nsComponentManager.cpp
--- a/xpcom/components/nsComponentManager.cpp
+++ b/xpcom/components/nsComponentManager.cpp
@@ -1744,17 +1744,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)