Bug 1521907 part 6. Start using CheckedUnwrapStatic/Dynamic in toolkit. r=peterv
☠☠ backed out by 0afc21b5734a ☠ ☠
authorBoris Zbarsky <bzbarsky@mit.edu>
Fri, 01 Feb 2019 13:22:44 +0000
changeset 456460 efd05f4979f176594f43f8d0a46af9fabd504664
parent 456459 2d089514890716397b1cee3f4ade5dc43218319e
child 456461 ce3108090e77f23b3272e1de2c463a68035bf963
push id111652
push userncsoregi@mozilla.com
push dateFri, 01 Feb 2019 22:14:41 +0000
treeherdermozilla-inbound@a36422c1abbc [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;