Bug 996077 - Null-check |holder|, and warn if SetWeakMapEntry fails. r=bz
authorBobby Holley <bobbyholley@gmail.com>
Mon, 14 Apr 2014 14:17:53 -0700
changeset 196907 fb250395c0b178a309f73c8344f4b55c9e93dd42
parent 196906 4f42a748cfaa993e07798bf7da5a9e74511e9b7d
child 196908 a79661f16f410b77ac53caba023091b20bca1741
push id3624
push userasasaki@mozilla.com
push dateMon, 09 Jun 2014 21:49:01 +0000
treeherdermozilla-beta@b1a5da15899a [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
reviewersbz
bugs996077
milestone31.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 996077 - Null-check |holder|, and warn if SetWeakMapEntry fails. r=bz
dom/xbl/nsXBLBinding.cpp
--- a/dom/xbl/nsXBLBinding.cpp
+++ b/dom/xbl/nsXBLBinding.cpp
@@ -952,16 +952,18 @@ GetOrCreateMapEntryForPrototype(JSContex
   // We don't have an entry. Create one and stick it in the map.
   JS::Rooted<JSObject*> entry(cx);
   entry = JS_NewObjectWithGivenProto(cx, nullptr, JS::NullPtr(), scope);
   if (!entry) {
     return nullptr;
   }
   JS::Rooted<JS::Value> entryVal(cx, JS::ObjectValue(*entry));
   if (!JS::SetWeakMapEntry(cx, map, wrappedProto, entryVal)) {
+    NS_WARNING("SetWeakMapEntry failed, probably due to non-preservable WeakMap "
+               "key. XBL binding will fail for this element.");
     return nullptr;
   }
   return entry;
 }
 
 // static
 nsresult
 nsXBLBinding::DoInitJSClass(JSContext *cx,
@@ -992,16 +994,19 @@ nsXBLBinding::DoInitJSClass(JSContext *c
   // as a property holder.
   JS::Rooted<JSObject*> holder(cx);
   if (parent_proto) {
     holder = GetOrCreateMapEntryForPrototype(cx, parent_proto);
   } else {
     JSAutoCompartment innerAC(cx, xblScope);
     holder = GetOrCreateClassObjectMap(cx, xblScope, "__ContentClassObjectMap__");
   }
+  if (NS_WARN_IF(!holder)) {
+    return NS_ERROR_FAILURE;
+  }
   js::AssertSameCompartment(holder, xblScope);
   JSAutoCompartment ac(cx, holder);
 
   // Look up the class on the property holder. The only properties on the
   // holder should be class objects. If we don't find the class object, we need
   // to create and define it.
   JS::Rooted<JSObject*> proto(cx);
   JS::Rooted<JSPropertyDescriptor> desc(cx);