Bug 1521907 part 6. Start using CheckedUnwrapStatic/Dynamic in toolkit. r=peterv
authorBoris Zbarsky <bzbarsky@mit.edu>
Sat, 02 Feb 2019 03:25:07 +0000
changeset 456534 f39008382451ae45616ff3263421c2affc716cbc
parent 456533 a0b9977daa361c63bae40a7caf6dbfd2130558fa
child 456535 5473faa3c4b031839c7a91507665f98a68880188
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;