Bug 1029632 - prevent leaks through adding pref cache, r=bz, a=sylvestre
authorGijs Kruitbosch <gijskruitbosch@gmail.com>
Tue, 24 Jun 2014 18:13:25 +0100
changeset 207336 53f73bdf51241c4abb6a6974f8fe51b4988e9599
parent 207335 bf28f13cb7ac855be8ff7a7b169274517e8c90e8
child 207337 fbdfb0c35e8ecdae2b65ed197d1262ff289c226c
push id3741
push userasasaki@mozilla.com
push dateMon, 21 Jul 2014 20:25:18 +0000
treeherdermozilla-beta@4d6f46f5af68 [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
reviewersbz, sylvestre
bugs1029632
milestone32.0a2
Bug 1029632 - prevent leaks through adding pref cache, r=bz, a=sylvestre
docshell/base/nsDefaultURIFixup.cpp
--- a/docshell/base/nsDefaultURIFixup.cpp
+++ b/docshell/base/nsDefaultURIFixup.cpp
@@ -23,16 +23,17 @@
 #include "nsIObserverService.h"
 #include "nsXULAppAPI.h"
 
 using namespace mozilla;
 
 /* Implementation file */
 NS_IMPL_ISUPPORTS(nsDefaultURIFixup, nsIURIFixup)
 
+static bool sInitializedPrefCaches = false;
 static bool sFixTypos = true;
 
 nsDefaultURIFixup::nsDefaultURIFixup()
 {
   /* member initializers and constructor code */
 }
 
 
@@ -198,22 +199,25 @@ nsDefaultURIFixup::CreateFixupURI(const 
                 if (*start == '\\')
                     *start = '/';
                 ++start;
             }
         }
 #endif
     }
 
-    // Check if we want to fix up common scheme typos.
-    rv = Preferences::AddBoolVarCache(&sFixTypos,
-                                      "browser.fixup.typo.scheme",
-                                      sFixTypos);
-    MOZ_ASSERT(NS_SUCCEEDED(rv),
-              "Failed to observe \"browser.fixup.typo.scheme\"");
+    if (!sInitializedPrefCaches) {
+      // Check if we want to fix up common scheme typos.
+      rv = Preferences::AddBoolVarCache(&sFixTypos,
+                                        "browser.fixup.typo.scheme",
+                                        sFixTypos);
+      MOZ_ASSERT(NS_SUCCEEDED(rv),
+                "Failed to observe \"browser.fixup.typo.scheme\"");
+      sInitializedPrefCaches = true;
+    }
 
     // Fix up common scheme typos.
     if (sFixTypos && (aFixupFlags & FIXUP_FLAG_FIX_SCHEME_TYPOS)) {
 
         // Fast-path for common cases.
         if (scheme.IsEmpty() ||
             scheme.LowerCaseEqualsLiteral("http") ||
             scheme.LowerCaseEqualsLiteral("https") ||