Bug 1134016: Initialize the global has table pointer, check for the default preference before testing its value. r?bsmedberg draft
authorMilan Sreckovic <milan@mozilla.com>
Tue, 25 Oct 2016 11:24:51 -0700
changeset 429322 f4fab6049280aa7217385f4601b4e02608559e7e
parent 428736 c845bfd0accb7e0c29b41713255963b08006e701
child 534951 ce5b0118f7f58c3080cb0d9792c23983eaa207bc
push id33544
push usermsreckovic@mozilla.com
push dateTue, 25 Oct 2016 18:25:09 +0000
reviewersbsmedberg
bugs1134016
milestone52.0a1
Bug 1134016: Initialize the global has table pointer, check for the default preference before testing its value. r?bsmedberg MozReview-Commit-ID: Eudu8EaeItP
modules/libpref/prefapi.cpp
--- a/modules/libpref/prefapi.cpp
+++ b/modules/libpref/prefapi.cpp
@@ -62,17 +62,17 @@ matchPrefEntry(const PLDHashEntryHdr* en
     if (prefEntry->key == key) return true;
 
     if (!prefEntry->key || !key) return false;
 
     const char *otherKey = reinterpret_cast<const char*>(key);
     return (strcmp(prefEntry->key, otherKey) == 0);
 }
 
-PLDHashTable*       gHashTable;
+PLDHashTable*       gHashTable = nullptr;
 static PLArenaPool  gPrefNameArena;
 
 static struct CallbackNode* gCallbacks = nullptr;
 static bool         gIsAnyPrefLocked = false;
 // These are only used during the call to pref_DoCallback
 static bool         gCallbacksInProgress = false;
 static bool         gShouldCleanupDeadNodes = false;
 
@@ -349,20 +349,20 @@ pref_savePrefs(PLDHashTable* aTable, uin
         nsAutoCString prefValue;
         nsAutoCString prefPrefix;
         prefPrefix.AssignLiteral("user_pref(\"");
 
         // where we're getting our pref from
         PrefValue* sourcePref;
 
         if (pref->prefFlags.HasUserValue() &&
-            (pref_ValueChanged(pref->defaultPref,
+            (!(pref->prefFlags.HasDefault()) ||
+             pref_ValueChanged(pref->defaultPref,
                                pref->userPref,
                                pref->prefFlags.GetPrefType()) ||
-             !(pref->prefFlags.HasDefault()) ||
              pref->prefFlags.HasStickyDefault())) {
             sourcePref = &pref->userPref;
         } else {
             // do not save default prefs that haven't changed
             continue;
         }
 
         // strings are in quotes!