Bug 1072150 - Crash in SubjectPrincipal if there's no active AutoJSAPI. r=bz
authorBobby Holley <bobbyholley@gmail.com>
Thu, 25 Sep 2014 10:48:05 +0200
changeset 264249 f23c63830ae5e3ba26858dcfd118b180884c98d7
parent 264248 4d962ac45aee707120233d79a15071f908e4f1cc
child 264250 3d01fdb4df6a1d5a8ac99025537505ad9e0de69c
push id65574
push userbobbyholley@gmail.com
push dateThu, 24 Sep 2015 21:02:47 +0000
treeherdermozilla-inbound@f23c63830ae5 [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
reviewersbz
bugs1072150
milestone44.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 1072150 - Crash in SubjectPrincipal if there's no active AutoJSAPI. r=bz
dom/base/nsContentUtils.cpp
--- a/dom/base/nsContentUtils.cpp
+++ b/dom/base/nsContentUtils.cpp
@@ -2705,17 +2705,17 @@ nsContentUtils::GenerateStateKey(nsICont
 // static
 nsIPrincipal*
 nsContentUtils::SubjectPrincipal()
 {
   MOZ_ASSERT(IsInitialized());
   MOZ_ASSERT(NS_IsMainThread());
   JSContext* cx = GetCurrentJSContext();
   if (!cx) {
-    return GetSystemPrincipal();
+    MOZ_CRASH("Accessing the Subject Principal without an AutoJSAPI on the stack is forbidden");
   }
 
   JSCompartment *compartment = js::GetContextCompartment(cx);
 
   // When an AutoJSAPI is instantiated, we are in a null compartment until the
   // first JSAutoCompartment, which is kind of a purgatory as far as permissions
   // go. It would be nice to just hard-abort if somebody does a security check
   // in this purgatory zone, but that would be too fragile, since it could be