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 279863 dd3a10e8fcce
parent 279862 3791e857a33f
child 279864 4a2537c6614b
push id17010
push usercbook@mozilla.com
push dateThu, 14 Jan 2016 09:48:26 +0000
treeherderfx-team@dd3a10e8fcce [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
reviewersbholley
bugs1157469
milestone46.0a1
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;