Bug 1521907 part 6. Start using CheckedUnwrapStatic/Dynamic in toolkit. r=peterv
☠☠ backed out by bcb403c04f1c ☠ ☠
authorBoris Zbarsky <bzbarsky@mit.edu>
Fri, 01 Feb 2019 18:49:45 +0000
changeset 456509 ac1c61bf61e990ea7100932636a096a1d09a049f
parent 456508 df09b7be63c5a642faf52ec29ff5da15d5ae4b04
child 456510 ef04359ccf0dfb82a65e82fbffff5143a60e941b
push id111656
push userdvarga@mozilla.com
push dateSat, 02 Feb 2019 09:51:54 +0000
treeherdermozilla-inbound@d8cebb3b46cf [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
reviewerspeterv
bugs1521907
milestone67.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 1521907 part 6. Start using CheckedUnwrapStatic/Dynamic in toolkit. r=peterv Differential Revision: https://phabricator.services.mozilla.com/D17886
toolkit/components/mozintl/MozIntlHelper.cpp
toolkit/recordreplay/ipc/JSControl.cpp
--- a/toolkit/components/mozintl/MozIntlHelper.cpp
+++ b/toolkit/components/mozintl/MozIntlHelper.cpp
@@ -25,17 +25,19 @@ MozIntlHelper::MozIntlHelper() = default
 MozIntlHelper::~MozIntlHelper() = default;
 
 static nsresult AddFunctions(JSContext* cx, JS::Handle<JS::Value> val,
                              const JSFunctionSpec* funcs) {
   if (!val.isObject()) {
     return NS_ERROR_INVALID_ARG;
   }
 
-  JS::Rooted<JSObject*> realIntlObj(cx, js::CheckedUnwrap(&val.toObject()));
+  // We might be adding functions to a Window.
+  JS::Rooted<JSObject*> realIntlObj(
+      cx, js::CheckedUnwrapDynamic(&val.toObject(), cx));
   if (!realIntlObj) {
     return NS_ERROR_INVALID_ARG;
   }
 
   JSAutoRealm ar(cx, realIntlObj);
 
   if (!JS_DefineFunctions(cx, realIntlObj, funcs)) {
     return NS_ERROR_FAILURE;
@@ -64,17 +66,19 @@ MozIntlHelper::AddGetDisplayNames(JS::Ha
 
 NS_IMETHODIMP
 MozIntlHelper::AddDateTimeFormatConstructor(JS::Handle<JS::Value> val,
                                             JSContext* cx) {
   if (!val.isObject()) {
     return NS_ERROR_INVALID_ARG;
   }
 
-  JS::Rooted<JSObject*> realIntlObj(cx, js::CheckedUnwrap(&val.toObject()));
+  // We might be adding this constructor to a Window
+  JS::Rooted<JSObject*> realIntlObj(
+      cx, js::CheckedUnwrapDynamic(&val.toObject(), cx));
   if (!realIntlObj) {
     return NS_ERROR_INVALID_ARG;
   }
 
   JSAutoRealm ar(cx, realIntlObj);
 
   if (!js::AddMozDateTimeFormatConstructor(cx, realIntlObj)) {
     return NS_ERROR_FAILURE;
--- a/toolkit/recordreplay/ipc/JSControl.cpp
+++ b/toolkit/recordreplay/ipc/JSControl.cpp
@@ -332,17 +332,19 @@ static bool Middleman_RegisterReplayDebu
     }
 
     if (NS_FAILED(gControl->ConnectDebugger(debuggerValue))) {
       JS_ReportErrorASCII(aCx, "ConnectDebugger failed\n");
       return false;
     }
   }
 
-  obj = ::js::CheckedUnwrap(obj);
+  // Who knows what values are being passed here.  Play it safe and do
+  // CheckedUnwrapDynamic.
+  obj = ::js::CheckedUnwrapDynamic(obj, aCx);
   if (!obj) {
     ::js::ReportAccessDenied(aCx);
     return false;
   }
 
   gReplayDebugger = new PersistentRootedObject(aCx);
   *gReplayDebugger = obj;