mirror of
https://gitlab.winehq.org/wine/wine-gecko.git
synced 2024-09-13 09:24:08 -07:00
Don't crash if NP_Initialize failed remotely: PluginLibrary::NP_Initialize returns an nsresult, not a NPError; nsNPAPIPlugin::CreatePlugin fails but still sets the outparam; nsPluginHost doesn't properly rv-check nsNPAPIPlugin::CreatePlugin, which causes us to think the bad plugin is actually good. I hate stupid failure chains!
This commit is contained in:
parent
9a696edbf3
commit
bda0f732bc
@ -446,7 +446,7 @@ PluginModuleParent::NP_Initialize(NPNetscapeFuncs* bFuncs, NPPluginFuncs* pFuncs
|
||||
mNPNIface = bFuncs;
|
||||
|
||||
if (!CallNP_Initialize(error)) {
|
||||
return NPERR_GENERIC_ERROR;
|
||||
return NS_ERROR_FAILURE;
|
||||
}
|
||||
else if (*error != NPERR_NO_ERROR) {
|
||||
return NS_OK;
|
||||
@ -464,7 +464,7 @@ PluginModuleParent::NP_Initialize(NPNetscapeFuncs* bFuncs, NPError* error)
|
||||
mNPNIface = bFuncs;
|
||||
|
||||
if (!CallNP_Initialize(error))
|
||||
return NPERR_GENERIC_ERROR;
|
||||
return NS_ERROR_FAILURE;
|
||||
|
||||
return NS_OK;
|
||||
}
|
||||
|
@ -447,8 +447,10 @@ nsNPAPIPlugin::CreatePlugin(const char* aFilePath, PRLibrary* aLibrary,
|
||||
|
||||
NPError initError;
|
||||
nsresult initResult = pluginLib->NP_Initialize(&(nsNPAPIPlugin::CALLBACKS),&callbacks, &initError);
|
||||
if (initResult != NS_OK || initError != NPERR_NO_ERROR)
|
||||
if (initResult != NS_OK || initError != NPERR_NO_ERROR) {
|
||||
NS_RELEASE(*aResult);
|
||||
return NS_ERROR_UNEXPECTED;
|
||||
}
|
||||
|
||||
// now copy function table back to nsNPAPIPlugin instance
|
||||
memcpy((void*) &(plptr->fCallbacks), (void*)&callbacks, sizeof(callbacks));
|
||||
|
@ -4013,15 +4013,16 @@ NS_IMETHODIMP nsPluginHost::GetPlugin(const char *aMimeType, nsIPlugin** aPlugin
|
||||
if (!plugin) {
|
||||
// Now lets try to get the entry point from an NPAPI plugin
|
||||
rv = CreateNPAPIPlugin(pluginTag, &plugin);
|
||||
if (NS_SUCCEEDED(rv))
|
||||
pluginTag->mEntryPoint = plugin;
|
||||
if (NS_FAILED(rv))
|
||||
return rv;
|
||||
|
||||
NS_ASSERTION(plugin, "CreateNPAPIPlugin succeeded without setting 'plugin'");
|
||||
pluginTag->mEntryPoint = plugin;
|
||||
}
|
||||
|
||||
if (plugin) {
|
||||
*aPlugin = plugin;
|
||||
plugin->AddRef();
|
||||
return NS_OK;
|
||||
}
|
||||
*aPlugin = plugin;
|
||||
plugin->AddRef();
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
PLUGIN_LOG(PLUGIN_LOG_NORMAL,
|
||||
|
Loading…
Reference in New Issue
Block a user