From 88a1a3951cb42177a109d081d1938d97d40ac927 Mon Sep 17 00:00:00 2001 From: Jan de Mooij Date: Sat, 4 Aug 2018 15:30:40 +0200 Subject: [PATCH] Bug 1480678 part 6 - Use CheckedUnwrap in nsContentPermissionRequestProxy::Allow. r=mrbkap --- dom/base/nsContentPermissionHelper.cpp | 9 +++++++-- 1 file changed, 7 insertions(+), 2 deletions(-) diff --git a/dom/base/nsContentPermissionHelper.cpp b/dom/base/nsContentPermissionHelper.cpp index d8c3f8f06519..7d35a6c39306 100644 --- a/dom/base/nsContentPermissionHelper.cpp +++ b/dom/base/nsContentPermissionHelper.cpp @@ -708,12 +708,17 @@ nsContentPermissionRequestProxy::Allow(JS::HandleValue aChoices) for (uint32_t i = 0; i < mPermissionRequests.Length(); ++i) { nsCString type = mPermissionRequests[i].type(); + JS::Rooted obj(RootingCx(), &aChoices.toObject()); + obj = CheckedUnwrap(obj); + if (!obj) { + return NS_ERROR_FAILURE; + } + AutoJSAPI jsapi; jsapi.Init(); JSContext* cx = jsapi.cx(); - JS::Rooted obj(cx, &aChoices.toObject()); - JSAutoRealmAllowCCW ar(cx, obj); + JSAutoRealm ar(cx, obj); JS::Rooted val(cx);