summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorDavid Parks <daparks@mozilla.com>2019-12-06 12:28:18 +0100
committerwolfbeast <mcwerewolf@wolfbeast.com>2019-12-06 12:28:18 +0100
commit74f15fb2d6c0e6de7b15631aada9997d000bd8ac (patch)
tree9672fa8747ddd9e17c00f05da8987b9361dfe567
parent246bf49b0d637902cbc821232db60c40e123b80f (diff)
downloadUXP-74f15fb2d6c0e6de7b15631aada9997d000bd8ac.tar
UXP-74f15fb2d6c0e6de7b15631aada9997d000bd8ac.tar.gz
UXP-74f15fb2d6c0e6de7b15631aada9997d000bd8ac.tar.lz
UXP-74f15fb2d6c0e6de7b15631aada9997d000bd8ac.tar.xz
UXP-74f15fb2d6c0e6de7b15631aada9997d000bd8ac.zip
Properly detect failure in receiving plugin NPObjects.
Properly handles NPError reporting and makes sure that, in the case of failure, it does not return junk for the NPObject.
-rw-r--r--dom/plugins/ipc/PluginInstanceChild.cpp13
1 files changed, 8 insertions, 5 deletions
diff --git a/dom/plugins/ipc/PluginInstanceChild.cpp b/dom/plugins/ipc/PluginInstanceChild.cpp
index af9db9103..3f2cdbc13 100644
--- a/dom/plugins/ipc/PluginInstanceChild.cpp
+++ b/dom/plugins/ipc/PluginInstanceChild.cpp
@@ -310,9 +310,10 @@ PluginInstanceChild::InternalGetNPObjectForValue(NPNVariable aValue,
switch (aValue) {
case NPNVWindowNPObject:
if (!(actor = mCachedWindowActor)) {
+ result = NPERR_GENERIC_ERROR;
PPluginScriptableObjectChild* actorProtocol;
- CallNPN_GetValue_NPNVWindowNPObject(&actorProtocol, &result);
- if (result == NPERR_NO_ERROR) {
+ if (CallNPN_GetValue_NPNVWindowNPObject(&actorProtocol, &result) &&
+ result == NPERR_NO_ERROR) {
actor = mCachedWindowActor =
static_cast<PluginScriptableObjectChild*>(actorProtocol);
NS_ASSERTION(actor, "Null actor!");
@@ -324,10 +325,10 @@ PluginInstanceChild::InternalGetNPObjectForValue(NPNVariable aValue,
case NPNVPluginElementNPObject:
if (!(actor = mCachedElementActor)) {
+ result = NPERR_GENERIC_ERROR;
PPluginScriptableObjectChild* actorProtocol;
- CallNPN_GetValue_NPNVPluginElementNPObject(&actorProtocol,
- &result);
- if (result == NPERR_NO_ERROR) {
+ if (CallNPN_GetValue_NPNVPluginElementNPObject(&actorProtocol, &result) &&
+ result == NPERR_NO_ERROR) {
actor = mCachedElementActor =
static_cast<PluginScriptableObjectChild*>(actorProtocol);
NS_ASSERTION(actor, "Null actor!");
@@ -338,6 +339,7 @@ PluginInstanceChild::InternalGetNPObjectForValue(NPNVariable aValue,
break;
default:
+ result = NPERR_GENERIC_ERROR;
NS_NOTREACHED("Don't know what to do with this value type!");
}
@@ -434,6 +436,7 @@ PluginInstanceChild::NPN_GetValue(NPNVariable aVar,
case NPNVWindowNPObject: // Intentional fall-through
case NPNVPluginElementNPObject: {
NPObject* object;
+ *((NPObject**)aValue) = nullptr;
NPError result = InternalGetNPObjectForValue(aVar, &object);
if (result == NPERR_NO_ERROR) {
*((NPObject**)aValue) = object;