Bug 961490 - Some cleaner rooting in NPAPI _eval. r=terrence,bsmedberg
authorTom Schuster <evilpies@gmail.com>
Thu, 23 Jan 2014 20:49:40 +0100
changeset 164883 16805a1975cd3a7a830bb26722ca93eb643fe3b4
parent 164882 4e559e11306b3a8dcbfdf73ee673bcdfb8369c1a
child 164884 f9f11f19eca6b4f53295791334a894997289f642
push id38846
push userevilpies@gmail.com
push dateThu, 23 Jan 2014 19:50:16 +0000
treeherdermozilla-inbound@16805a1975cd [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
reviewersterrence, bsmedberg
bugs961490
milestone29.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 961490 - Some cleaner rooting in NPAPI _eval. r=terrence,bsmedberg
dom/plugins/base/nsNPAPIPlugin.cpp
--- a/dom/plugins/base/nsNPAPIPlugin.cpp
+++ b/dom/plugins/base/nsNPAPIPlugin.cpp
@@ -1501,21 +1501,16 @@ bool NP_CALLBACK
   if (!obj) {
     return false;
   }
 
   obj = JS_ObjectToInnerObject(cx, obj);
   NS_ABORT_IF_FALSE(obj,
     "JS_ObjectToInnerObject should never return null with non-null input.");
 
-  // Root obj and the rval (below).
-  JS::Value vec[] = { OBJECT_TO_JSVAL(obj), JSVAL_NULL };
-  JS::AutoArrayRooter tvr(cx, ArrayLength(vec), vec);
-  JS::Value *rval = &vec[1];
-
   if (result) {
     // Initialize the out param to void
     VOID_TO_NPVARIANT(*result);
   }
 
   if (!script || !script->UTF8Length || !script->UTF8Characters) {
     // Nothing to evaluate.
 
@@ -1558,22 +1553,23 @@ bool NP_CALLBACK
 
   NPN_PLUGIN_LOG(PLUGIN_LOG_NOISY,
                  ("NPN_Evaluate(npp %p, npobj %p, script <<<%s>>>) called\n",
                   npp, npobj, script->UTF8Characters));
 
   JS::CompileOptions options(cx);
   options.setFileAndLine(spec, 0)
          .setVersion(JSVERSION_DEFAULT);
+  JS::Rooted<JS::Value> rval(cx);
   nsresult rv = scx->EvaluateString(utf16script, obj, options,
                                     /* aCoerceToString = */ false,
-                                    rval);
+                                    rval.address());
 
   return NS_SUCCEEDED(rv) &&
-         (!result || JSValToNPVariant(npp, cx, *rval, result));
+         (!result || JSValToNPVariant(npp, cx, rval, result));
 }
 
 bool NP_CALLBACK
 _getproperty(NPP npp, NPObject* npobj, NPIdentifier property,
              NPVariant *result)
 {
   if (!NS_IsMainThread()) {
     NPN_PLUGIN_LOG(PLUGIN_LOG_ALWAYS,("NPN_getproperty called from the wrong thread\n"));