Commit c6eb13a2 authored by Brandon Sterne's avatar Brandon Sterne
Browse files

Bug 578182. CSP causing leaks due to repeated AddBoolPrefVarCache call from...

Bug 578182. CSP causing leaks due to repeated AddBoolPrefVarCache call from nsDocument constructor. r=dveditz
parent bd1bb051
Loading
Loading
Loading
Loading
+4 −4
Original line number Diff line number Diff line
@@ -55,7 +55,7 @@
#include "nsChannelProperties.h"

/* Keeps track of whether or not CSP is enabled */
static PRBool gCSPEnabled = PR_TRUE;
PRBool CSPService::sCSPEnabled = PR_TRUE;

#ifdef PR_LOGGING
static PRLogModuleInfo* gCspPRLog;
@@ -63,7 +63,7 @@ static PRLogModuleInfo* gCspPRLog;

CSPService::CSPService()
{
  nsContentUtils::AddBoolPrefVarCache("security.csp.enable", &gCSPEnabled);
  nsContentUtils::AddBoolPrefVarCache("security.csp.enable", &sCSPEnabled);

#ifdef PR_LOGGING
  if (!gCspPRLog)
@@ -102,7 +102,7 @@ CSPService::ShouldLoad(PRUint32 aContentType,
    *aDecision = nsIContentPolicy::ACCEPT;

    // No need to continue processing if CSP is disabled
    if (!gCSPEnabled)
    if (!sCSPEnabled)
        return NS_OK;

    // find the principal of the document that initiated this request and see
@@ -160,7 +160,7 @@ CSPService::ShouldProcess(PRUint32 aContentType,
    *aDecision = nsIContentPolicy::ACCEPT;

    // No need to continue processing if CSP is disabled
    if (!gCSPEnabled)
    if (!sCSPEnabled)
        return NS_OK;

    // find the nsDocument that initiated this request and see if it has a
+2 −1
Original line number Diff line number Diff line
@@ -55,4 +55,5 @@ public:

  CSPService();
  virtual ~CSPService();
  static PRBool sCSPEnabled;
};
+2 −6
Original line number Diff line number Diff line
@@ -195,6 +195,7 @@ static NS_DEFINE_CID(kDOMEventGroupCID, NS_DOMEVENTGROUP_CID);

// FOR CSP (autogenerated by xpidl)
#include "nsIContentSecurityPolicy.h"
#include "nsCSPService.h"
#include "nsHTMLStyleSheet.h"
#include "nsHTMLCSSStyleSheet.h"

@@ -202,9 +203,6 @@ static NS_DEFINE_CID(kDOMEventGroupCID, NS_DOMEVENTGROUP_CID);
using namespace mozilla::dom;


/* Keeps track of whether or not CSP is enabled */
static PRBool gCSPEnabled = PR_TRUE;

#ifdef PR_LOGGING
static PRLogModuleInfo* gDocumentLeakPRLog;
static PRLogModuleInfo* gCspPRLog;
@@ -1409,8 +1407,6 @@ nsDocument::nsDocument(const char* aContentType)
    gCspPRLog = PR_NewLogModule("CSP");
#endif

  nsContentUtils::AddBoolPrefVarCache("security.csp.enable", &gCSPEnabled);

  // Start out mLastStyleSheetSet as null, per spec
  SetDOMStringToNull(mLastStyleSheetSet);
}
@@ -2175,7 +2171,7 @@ nsDocument::StartDocumentLoad(const char* aCommand, nsIChannel* aChannel,
nsresult
nsDocument::InitCSP()
{
  if (gCSPEnabled) {
  if (CSPService::sCSPEnabled) {
    nsAutoString cspHeaderValue;
    nsAutoString cspROHeaderValue;