зеркало из https://github.com/mozilla/pjs.git
Fixing memory leak during start up, #35912
This commit is contained in:
Родитель
f36320943b
Коммит
7cf1b4fba1
|
@ -1786,10 +1786,19 @@ NS_IMETHODIMP nsPluginHostImpl::SetUpPluginInstance(const char *aMimeType,
|
|||
return NS_ERROR_OUT_OF_MEMORY;
|
||||
|
||||
// set up the peer for the instance
|
||||
peer->Initialize(aOwner, mimetype);
|
||||
peer->Initialize(aOwner, mimetype);
|
||||
|
||||
nsIPluginInstancePeer *pi;
|
||||
|
||||
result = peer->QueryInterface(kIPluginInstancePeerIID, (void **)&pi);
|
||||
|
||||
if(result != NS_OK)
|
||||
return result;
|
||||
|
||||
// tell the plugin instance to initialize itself and pass in the peer.
|
||||
instance->Initialize(peer); // this will not add a ref to the instance (or owner). MMP
|
||||
instance->Initialize(pi); // this will not add a ref to the instance (or owner). MMP
|
||||
|
||||
NS_RELEASE(pi);
|
||||
|
||||
AddInstanceToActiveList(instance, aURL);
|
||||
|
||||
|
@ -2169,7 +2178,8 @@ NS_IMETHODIMP nsPluginHostImpl::LoadPlugins()
|
|||
if (pluginFile.LoadPlugin(pluginLibrary) == NS_OK && pluginLibrary != NULL) {
|
||||
#endif
|
||||
// create a tag describing this plugin.
|
||||
nsPluginTag* pluginTag = new nsPluginTag();
|
||||
/*
|
||||
nsPluginTag* pluginTag = new nsPluginTag();
|
||||
if(pluginTag == nsnull)
|
||||
return NS_ERROR_OUT_OF_MEMORY;
|
||||
|
||||
|
@ -2193,6 +2203,23 @@ NS_IMETHODIMP nsPluginHostImpl::LoadPlugins()
|
|||
pluginTag->mLibrary = pluginLibrary;
|
||||
pluginTag->mEntryPoint = NULL;
|
||||
pluginTag->mFlags = 0;
|
||||
*/
|
||||
nsPluginInfo info = { sizeof(info) };
|
||||
if (pluginFile.GetPluginInfo(info) != NS_OK)
|
||||
return NS_ERROR_FAILURE;
|
||||
|
||||
nsPluginTag* pluginTag = new nsPluginTag(&info);
|
||||
|
||||
pluginFile.FreePluginInfo(info);
|
||||
|
||||
if(pluginTag == nsnull)
|
||||
return NS_ERROR_OUT_OF_MEMORY;
|
||||
|
||||
pluginTag->mNext = mPlugins;
|
||||
mPlugins = pluginTag;
|
||||
|
||||
pluginTag->mLibrary = pluginLibrary;
|
||||
|
||||
#ifndef XP_WIN
|
||||
}
|
||||
#endif
|
||||
|
@ -2281,6 +2308,9 @@ NS_IMETHODIMP nsPluginHostImpl::LoadPlugins()
|
|||
return NS_ERROR_FAILURE;
|
||||
|
||||
nsPluginTag* pluginTag = new nsPluginTag(&info);
|
||||
|
||||
pluginFile.FreePluginInfo(info);
|
||||
|
||||
if(pluginTag == nsnull)
|
||||
return NS_ERROR_OUT_OF_MEMORY;
|
||||
|
||||
|
@ -2315,6 +2345,9 @@ NS_IMETHODIMP nsPluginHostImpl::LoadPlugins()
|
|||
return NS_ERROR_FAILURE;
|
||||
|
||||
nsPluginTag* pluginTag = new nsPluginTag(&info);
|
||||
|
||||
pluginFile.FreePluginInfo(info);
|
||||
|
||||
if(pluginTag == nsnull)
|
||||
return NS_ERROR_OUT_OF_MEMORY;
|
||||
|
||||
|
|
|
@ -95,6 +95,11 @@ public:
|
|||
* Obtains all of the information currently available for this plugin.
|
||||
*/
|
||||
nsresult GetPluginInfo(nsPluginInfo &outPluginInfo);
|
||||
|
||||
/**
|
||||
* Should be called after GetPluginInfo to free all allocated stuff
|
||||
*/
|
||||
nsresult FreePluginInfo(nsPluginInfo &PluginInfo);
|
||||
};
|
||||
|
||||
#endif /* nsPluginsDir_h___ */
|
||||
|
|
|
@ -176,3 +176,8 @@ nsresult nsPluginFile::GetPluginInfo(nsPluginInfo& info)
|
|||
}
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
nsresult nsPluginFile::FreePluginInfo(nsPluginInfo& info)
|
||||
{
|
||||
return NS_OK;
|
||||
}
|
||||
|
|
|
@ -221,3 +221,8 @@ nsresult nsPluginFile::GetPluginInfo( nsPluginInfo &info)
|
|||
|
||||
return rc;
|
||||
}
|
||||
|
||||
nsresult nsPluginFile::FreePluginInfo(nsPluginInfo& info)
|
||||
{
|
||||
return NS_OK;
|
||||
}
|
||||
|
|
|
@ -225,4 +225,8 @@ nsresult nsPluginFile::GetPluginInfo(nsPluginInfo& info)
|
|||
return NS_OK;
|
||||
}
|
||||
|
||||
nsresult nsPluginFile::FreePluginInfo(nsPluginInfo& info)
|
||||
{
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
|
|
|
@ -184,7 +184,7 @@ nsPluginsDir::nsPluginsDir(PRUint16 location)
|
|||
::RegCloseKey(keyloc);
|
||||
}
|
||||
|
||||
allocPath = PL_strdup(path);
|
||||
allocPath = path;
|
||||
*(nsFileSpec*)this = allocPath;
|
||||
}
|
||||
|
||||
|
@ -315,9 +315,39 @@ nsresult nsPluginFile::GetPluginInfo(nsPluginInfo& info)
|
|||
else
|
||||
res = NS_ERROR_FAILURE;
|
||||
|
||||
|
||||
PR_Free(verbuf);
|
||||
|
||||
return res;
|
||||
}
|
||||
|
||||
nsresult nsPluginFile::FreePluginInfo(nsPluginInfo& info)
|
||||
{
|
||||
if(info.fName != nsnull)
|
||||
PL_strfree(info.fName);
|
||||
|
||||
if(info.fDescription != nsnull)
|
||||
PL_strfree(info.fDescription);
|
||||
|
||||
if(info.fMimeType != nsnull)
|
||||
PL_strfree(info.fMimeType);
|
||||
|
||||
if(info.fMimeDescription != nsnull)
|
||||
PL_strfree(info.fMimeDescription);
|
||||
|
||||
if(info.fExtensions != nsnull)
|
||||
PL_strfree(info.fExtensions);
|
||||
|
||||
if(info.fMimeTypeArray != nsnull)
|
||||
PR_Free(info.fMimeTypeArray);
|
||||
|
||||
if(info.fMimeDescriptionArray != nsnull)
|
||||
PR_Free(info.fMimeDescriptionArray);
|
||||
|
||||
if(info.fExtensionArray != nsnull)
|
||||
PR_Free(info.fExtensionArray);
|
||||
|
||||
ZeroMemory((void *)&info, sizeof(info));
|
||||
|
||||
return NS_OK;
|
||||
}
|
||||
|
|
|
@ -1786,10 +1786,19 @@ NS_IMETHODIMP nsPluginHostImpl::SetUpPluginInstance(const char *aMimeType,
|
|||
return NS_ERROR_OUT_OF_MEMORY;
|
||||
|
||||
// set up the peer for the instance
|
||||
peer->Initialize(aOwner, mimetype);
|
||||
peer->Initialize(aOwner, mimetype);
|
||||
|
||||
nsIPluginInstancePeer *pi;
|
||||
|
||||
result = peer->QueryInterface(kIPluginInstancePeerIID, (void **)&pi);
|
||||
|
||||
if(result != NS_OK)
|
||||
return result;
|
||||
|
||||
// tell the plugin instance to initialize itself and pass in the peer.
|
||||
instance->Initialize(peer); // this will not add a ref to the instance (or owner). MMP
|
||||
instance->Initialize(pi); // this will not add a ref to the instance (or owner). MMP
|
||||
|
||||
NS_RELEASE(pi);
|
||||
|
||||
AddInstanceToActiveList(instance, aURL);
|
||||
|
||||
|
@ -2169,7 +2178,8 @@ NS_IMETHODIMP nsPluginHostImpl::LoadPlugins()
|
|||
if (pluginFile.LoadPlugin(pluginLibrary) == NS_OK && pluginLibrary != NULL) {
|
||||
#endif
|
||||
// create a tag describing this plugin.
|
||||
nsPluginTag* pluginTag = new nsPluginTag();
|
||||
/*
|
||||
nsPluginTag* pluginTag = new nsPluginTag();
|
||||
if(pluginTag == nsnull)
|
||||
return NS_ERROR_OUT_OF_MEMORY;
|
||||
|
||||
|
@ -2193,6 +2203,23 @@ NS_IMETHODIMP nsPluginHostImpl::LoadPlugins()
|
|||
pluginTag->mLibrary = pluginLibrary;
|
||||
pluginTag->mEntryPoint = NULL;
|
||||
pluginTag->mFlags = 0;
|
||||
*/
|
||||
nsPluginInfo info = { sizeof(info) };
|
||||
if (pluginFile.GetPluginInfo(info) != NS_OK)
|
||||
return NS_ERROR_FAILURE;
|
||||
|
||||
nsPluginTag* pluginTag = new nsPluginTag(&info);
|
||||
|
||||
pluginFile.FreePluginInfo(info);
|
||||
|
||||
if(pluginTag == nsnull)
|
||||
return NS_ERROR_OUT_OF_MEMORY;
|
||||
|
||||
pluginTag->mNext = mPlugins;
|
||||
mPlugins = pluginTag;
|
||||
|
||||
pluginTag->mLibrary = pluginLibrary;
|
||||
|
||||
#ifndef XP_WIN
|
||||
}
|
||||
#endif
|
||||
|
@ -2281,6 +2308,9 @@ NS_IMETHODIMP nsPluginHostImpl::LoadPlugins()
|
|||
return NS_ERROR_FAILURE;
|
||||
|
||||
nsPluginTag* pluginTag = new nsPluginTag(&info);
|
||||
|
||||
pluginFile.FreePluginInfo(info);
|
||||
|
||||
if(pluginTag == nsnull)
|
||||
return NS_ERROR_OUT_OF_MEMORY;
|
||||
|
||||
|
@ -2315,6 +2345,9 @@ NS_IMETHODIMP nsPluginHostImpl::LoadPlugins()
|
|||
return NS_ERROR_FAILURE;
|
||||
|
||||
nsPluginTag* pluginTag = new nsPluginTag(&info);
|
||||
|
||||
pluginFile.FreePluginInfo(info);
|
||||
|
||||
if(pluginTag == nsnull)
|
||||
return NS_ERROR_OUT_OF_MEMORY;
|
||||
|
||||
|
|
|
@ -95,6 +95,11 @@ public:
|
|||
* Obtains all of the information currently available for this plugin.
|
||||
*/
|
||||
nsresult GetPluginInfo(nsPluginInfo &outPluginInfo);
|
||||
|
||||
/**
|
||||
* Should be called after GetPluginInfo to free all allocated stuff
|
||||
*/
|
||||
nsresult FreePluginInfo(nsPluginInfo &PluginInfo);
|
||||
};
|
||||
|
||||
#endif /* nsPluginsDir_h___ */
|
||||
|
|
|
@ -176,3 +176,8 @@ nsresult nsPluginFile::GetPluginInfo(nsPluginInfo& info)
|
|||
}
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
nsresult nsPluginFile::FreePluginInfo(nsPluginInfo& info)
|
||||
{
|
||||
return NS_OK;
|
||||
}
|
||||
|
|
|
@ -221,3 +221,8 @@ nsresult nsPluginFile::GetPluginInfo( nsPluginInfo &info)
|
|||
|
||||
return rc;
|
||||
}
|
||||
|
||||
nsresult nsPluginFile::FreePluginInfo(nsPluginInfo& info)
|
||||
{
|
||||
return NS_OK;
|
||||
}
|
||||
|
|
|
@ -184,7 +184,7 @@ nsPluginsDir::nsPluginsDir(PRUint16 location)
|
|||
::RegCloseKey(keyloc);
|
||||
}
|
||||
|
||||
allocPath = PL_strdup(path);
|
||||
allocPath = path;
|
||||
*(nsFileSpec*)this = allocPath;
|
||||
}
|
||||
|
||||
|
@ -315,9 +315,39 @@ nsresult nsPluginFile::GetPluginInfo(nsPluginInfo& info)
|
|||
else
|
||||
res = NS_ERROR_FAILURE;
|
||||
|
||||
|
||||
PR_Free(verbuf);
|
||||
|
||||
return res;
|
||||
}
|
||||
|
||||
nsresult nsPluginFile::FreePluginInfo(nsPluginInfo& info)
|
||||
{
|
||||
if(info.fName != nsnull)
|
||||
PL_strfree(info.fName);
|
||||
|
||||
if(info.fDescription != nsnull)
|
||||
PL_strfree(info.fDescription);
|
||||
|
||||
if(info.fMimeType != nsnull)
|
||||
PL_strfree(info.fMimeType);
|
||||
|
||||
if(info.fMimeDescription != nsnull)
|
||||
PL_strfree(info.fMimeDescription);
|
||||
|
||||
if(info.fExtensions != nsnull)
|
||||
PL_strfree(info.fExtensions);
|
||||
|
||||
if(info.fMimeTypeArray != nsnull)
|
||||
PR_Free(info.fMimeTypeArray);
|
||||
|
||||
if(info.fMimeDescriptionArray != nsnull)
|
||||
PR_Free(info.fMimeDescriptionArray);
|
||||
|
||||
if(info.fExtensionArray != nsnull)
|
||||
PR_Free(info.fExtensionArray);
|
||||
|
||||
ZeroMemory((void *)&info, sizeof(info));
|
||||
|
||||
return NS_OK;
|
||||
}
|
||||
|
|
Загрузка…
Ссылка в новой задаче