diff --git a/docshell/shistory/src/nsSHistory.cpp b/docshell/shistory/src/nsSHistory.cpp index e71157f4c4e..f26260b58e6 100644 --- a/docshell/shistory/src/nsSHistory.cpp +++ b/docshell/shistory/src/nsSHistory.cpp @@ -220,14 +220,23 @@ nsSHistory::Startup() { nsCOMPtr prefs = do_GetService(NS_PREFSERVICE_CONTRACTID); if (prefs) { - // Session history size is only taken from the default prefs branch. - // This means that it's only configurable on a per-application basis. + nsCOMPtr sesHBranch; + prefs->GetBranch(nsnull, getter_AddRefs(sesHBranch)); + if (sesHBranch) { + sesHBranch->GetIntPref(PREF_SHISTORY_SIZE, &gHistoryMaxSize); + } + // The goal of this is to unbreak users who have inadvertently set their - // session history size to -1. + // session history size to less than the default value. + PRInt32 defaultHistoryMaxSize = 50; nsCOMPtr defaultBranch; prefs->GetDefaultBranch(nsnull, getter_AddRefs(defaultBranch)); if (defaultBranch) { - defaultBranch->GetIntPref(PREF_SHISTORY_SIZE, &gHistoryMaxSize); + defaultBranch->GetIntPref(PREF_SHISTORY_SIZE, &defaultHistoryMaxSize); + } + + if (gHistoryMaxSize < defaultHistoryMaxSize) { + gHistoryMaxSize = defaultHistoryMaxSize; } // Allow the user to override the max total number of cached viewers,