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:
Benjamin Smedberg 2009-11-20 10:34:20 -05:00
parent 9a696edbf3
commit bda0f732bc
3 changed files with 13 additions and 10 deletions

View File

@ -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;
}

View File

@ -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));

View File

@ -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,