From 98273f7667d59f058f651e3460b9fe901cf753af Mon Sep 17 00:00:00 2001 From: "bzbarsky%mit.edu" Date: Sat, 17 Apr 2004 23:23:19 +0000 Subject: [PATCH] Switch to nsCOMPtr to fix possible leaks and a possible strict aliasing violation. Bug 240710, r+sr=roc git-svn-id: svn://10.0.0.236/trunk@155048 18797224-902f-48f8-a5cc-f745e15eee43 --- .../modules/plugin/base/src/nsPluginHostImpl.cpp | 14 ++++++-------- 1 file changed, 6 insertions(+), 8 deletions(-) diff --git a/mozilla/modules/plugin/base/src/nsPluginHostImpl.cpp b/mozilla/modules/plugin/base/src/nsPluginHostImpl.cpp index 47780576048..48124102b5a 100644 --- a/mozilla/modules/plugin/base/src/nsPluginHostImpl.cpp +++ b/mozilla/modules/plugin/base/src/nsPluginHostImpl.cpp @@ -3883,8 +3883,8 @@ nsresult nsPluginHostImpl::SetUpDefaultPluginInstance(const char *aMimeType, nsI nsIPluginInstanceOwner *aOwner) { nsresult result = NS_ERROR_FAILURE; - nsIPluginInstance* instance = NULL; - nsCOMPtr plugin = NULL; + nsCOMPtr instance; + nsCOMPtr plugin; if(!aURL) return NS_ERROR_FAILURE; @@ -3895,14 +3895,15 @@ nsresult nsPluginHostImpl::SetUpDefaultPluginInstance(const char *aMimeType, nsI GetPluginFactory("*", getter_AddRefs(plugin)); - result = CallCreateInstance(NS_INLINE_PLUGIN_CONTRACTID_PREFIX "*", - &instance); + instance = do_CreateInstance(NS_INLINE_PLUGIN_CONTRACTID_PREFIX "*", + &result); // couldn't create an XPCOM plugin, try to create wrapper for a legacy plugin if (NS_FAILED(result)) { if(plugin) - result = plugin->CreateInstance(NULL, kIPluginInstanceIID, (void **)&instance); + result = plugin->CreateInstance(NULL, kIPluginInstanceIID, + getter_AddRefs(instance)); } // neither an XPCOM or legacy plugin could be instantiated, so return the failure @@ -3948,9 +3949,6 @@ nsresult nsPluginHostImpl::SetUpDefaultPluginInstance(const char *aMimeType, nsI // instance and peer will be addreffed here result = AddInstanceToActiveList(plugin, instance, aURL, PR_TRUE, pIpeer); - //release what was addreffed in Create(Plugin)Instance - NS_RELEASE(instance); - return result; }