Bug 1157469 - null check wrapper in case WrapNode fails, r=bholley
authorOlli Pettay <Olli.Pettay@helsinki.fi>
Mon, 11 Jan 2016 20:32:12 +0200
changeset 279971 dd3a10e8fcce
parent 279970 3791e857a33f
child 279972 4a2537c6614b
push id29899
push usercbook@mozilla.com
push dateFri, 15 Jan 2016 10:39:04 +0000
treeherdermozilla-central@7a91754ea083 [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
reviewersbholley
bugs1157469
milestone46.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 1157469 - null check wrapper in case WrapNode fails, r=bholley
dom/base/nsINode.cpp
dom/bindings/BindingUtils.h
--- a/dom/base/nsINode.cpp
+++ b/dom/base/nsINode.cpp
@@ -2774,18 +2774,19 @@ nsINode::WrapObject(JSContext *aCx, JS::
   if (!OwnerDoc()->GetScriptHandlingObject(hasHadScriptHandlingObject) &&
       !hasHadScriptHandlingObject &&
       !nsContentUtils::IsCallerChrome()) {
     Throw(aCx, NS_ERROR_UNEXPECTED);
     return nullptr;
   }
 
   JS::Rooted<JSObject*> obj(aCx, WrapNode(aCx, aGivenProto));
-  MOZ_ASSERT_IF(ChromeOnlyAccess(),
-                xpc::IsInContentXBLScope(obj) || !xpc::UseContentXBLScope(js::GetObjectCompartment(obj)));
+  MOZ_ASSERT_IF(obj && ChromeOnlyAccess(),
+                xpc::IsInContentXBLScope(obj) ||
+                !xpc::UseContentXBLScope(js::GetObjectCompartment(obj)));
   return obj;
 }
 
 already_AddRefed<nsINode>
 nsINode::CloneNode(bool aDeep, ErrorResult& aError)
 {
   nsCOMPtr<nsINode> result;
   aError = nsNodeUtils::CloneNodeImpl(this, aDeep, getter_AddRefs(result));
--- a/dom/bindings/BindingUtils.h
+++ b/dom/bindings/BindingUtils.h
@@ -1589,17 +1589,17 @@ static inline JSObject*
 WrapNativeParent(JSContext* cx, T* p, nsWrapperCache* cache,
                  bool useXBLScope = false)
 {
   if (!p) {
     return JS::CurrentGlobalOrNull(cx);
   }
 
   JSObject* parent = WrapNativeParentHelper<T>::Wrap(cx, p, cache);
-  if (!useXBLScope) {
+  if (!parent || !useXBLScope) {
     return parent;
   }
 
   // If useXBLScope is true, it means that the canonical reflector for this
   // native object should live in the content XBL scope. Note that we never put
   // anonymous content inside an add-on scope.
   if (xpc::IsInContentXBLScope(parent)) {
     return parent;