Bug 1134016: Initialize the global has table pointer, check for the default preference before testing its value. r?bsmedberg
MozReview-Commit-ID: Eudu8EaeItP
--- 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!