Bug 1449736: Properly detect failure in receiving plugin NPObjects r=jmathies
authorDavid Parks <daparks@mozilla.com>
Sat, 12 Oct 2019 17:05:35 +0000
changeset 500446 e017a75fabe40fad39edd3dbfc3a111636155684
parent 500445 7dfcfb109429c77b327956dc58d3e7eb6cd6e8ac
child 500447 586c8dec24bbf51a16c924e0f70596aea085758e
push id114164
push useraiakab@mozilla.com
push dateTue, 05 Nov 2019 10:06:15 +0000
treeherdermozilla-inbound@4d585c7edc76 [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
reviewersjmathies
bugs1449736
milestone72.0a1
first release with
nightly linux32
nightly linux64
nightly mac
nightly win32
nightly win64
last release without
nightly linux32
nightly linux64
nightly mac
nightly win32
nightly win64
Bug 1449736: Properly detect failure in receiving plugin NPObjects r=jmathies Properly handles NPError reporting and makes sure that, in the case of failure, it does not return junk for the NPObject. Differential Revision: https://phabricator.services.mozilla.com/D48474
dom/plugins/ipc/PluginInstanceChild.cpp
--- a/dom/plugins/ipc/PluginInstanceChild.cpp
+++ b/dom/plugins/ipc/PluginInstanceChild.cpp
@@ -267,49 +267,52 @@ int PluginInstanceChild::GetQuirks() {
 NPError PluginInstanceChild::InternalGetNPObjectForValue(NPNVariable aValue,
                                                          NPObject** aObject) {
   PluginScriptableObjectChild* actor = nullptr;
   NPError result = NPERR_NO_ERROR;
 
   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!");
           if (!actor->GetObject(false)) {
             return NPERR_GENERIC_ERROR;
           }
           PluginModuleChild::sBrowserFuncs.retainobject(
               actor->GetObject(false));
         }
       }
       break;
 
     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!");
           if (!actor->GetObject(false)) {
             return NPERR_GENERIC_ERROR;
           }
           PluginModuleChild::sBrowserFuncs.retainobject(
               actor->GetObject(false));
         }
       }
       break;
 
     default:
+      result = NPERR_GENERIC_ERROR;
       MOZ_ASSERT_UNREACHABLE(
           "Don't know what to do with this value "
           "type!");
   }
 
 #ifdef DEBUG
   {
     NPError currentResult;
@@ -395,16 +398,17 @@ NPError PluginInstanceChild::NPN_GetValu
         *static_cast<char**>(aValue) = ToNewCString(v);
       }
       return result;
     }
 
     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;
       }
       return result;
     }
 
     case NPNVnetscapeWindow: {