bug 530007: fix crashing edge cases in the hope of getting better diagnostics about failed tests

This commit is contained in:
Chris Jones 2009-11-20 02:23:07 -06:00
parent efb828a947
commit 9a696edbf3
2 changed files with 22 additions and 3 deletions

View File

@ -141,6 +141,9 @@ PluginModuleParent::NPP_Destroy(NPP instance,
PluginInstanceParent* parentInstance =
static_cast<PluginInstanceParent*>(instance->pdata);
if (!parentInstance)
return NPERR_NO_ERROR;
parentInstance->Destroy();
NPError prv;
@ -150,8 +153,7 @@ PluginModuleParent::NPP_Destroy(NPP instance,
instance->pdata = nsnull;
return prv;
}
}
bool
PluginModuleParent::EnsureValidNPIdentifier(NPIdentifier aIdentifier)
@ -542,6 +544,11 @@ PluginModuleParent::NPP_New(NPMIMEType pluginType, NPP instance,
names, values, error)) {
// |parentInstance| is automatically deleted.
instance->pdata = nsnull;
// if IPC is down, we'll get an immediate "failed" return, but
// without *error being set. So make sure that the error
// condition is signaled to nsNPAPIPluginInstance
if (NPERR_NO_ERROR == *error)
*error = NPERR_GENERIC_ERROR;
return NS_ERROR_FAILURE;
}

View File

@ -738,8 +738,20 @@ NPP_DestroyStream(NPP instance, NPStream* stream, NPReason reason)
if (instanceData->streamMode == NP_ASFILE &&
instanceData->functionToFail == FUNCTION_NONE) {
if (!instanceData->streamBuf) {
instanceData->err <<
"Error: no data written with NPP_Write";
return NPERR_GENERIC_ERROR;
}
if (!instanceData->fileBuf) {
instanceData->err <<
"Error: no data written with NPP_StreamAsFile";
return NPERR_GENERIC_ERROR;
}
if (strcmp(reinterpret_cast<char *>(instanceData->fileBuf),
reinterpret_cast<char *>(instanceData->streamBuf)) != 0) {
reinterpret_cast<char *>(instanceData->streamBuf))) {
instanceData->err <<
"Error: data passed to NPP_Write and NPP_StreamAsFile differed";
}