Bug 634936 - Add null-check for nsContentUtils::GetPrefBranch() to prevent Crash [@ nsFocusManager::Init ]; r=jst

This commit is contained in:
Ed Morley 2011-04-16 11:14:09 +02:00
Родитель 2f869e0bd1
Коммит 002581d137
2 изменённых файлов: 10 добавлений и 8 удалений

Просмотреть файл

@ -196,9 +196,11 @@ nsFocusManager::Init()
nsContentUtils::GetBoolPref("accessibility.mouse_focuses_formcontrol", PR_FALSE);
nsIPrefBranch2* prefBranch = nsContentUtils::GetPrefBranch();
prefBranch->AddObserver("accessibility.browsewithcaret", fm, PR_TRUE);
prefBranch->AddObserver("accessibility.tabfocus_applies_to_xul", fm, PR_TRUE);
prefBranch->AddObserver("accessibility.mouse_focuses_formcontrol", fm, PR_TRUE);
if (prefBranch) {
prefBranch->AddObserver("accessibility.browsewithcaret", fm, PR_TRUE);
prefBranch->AddObserver("accessibility.tabfocus_applies_to_xul", fm, PR_TRUE);
prefBranch->AddObserver("accessibility.mouse_focuses_formcontrol", fm, PR_TRUE);
}
nsCOMPtr<nsIObserverService> obs = mozilla::services::GetObserverService();
if (obs) {

Просмотреть файл

@ -1891,11 +1891,11 @@ static const char kIconLoadPrefs[][40] = {
nsImageFrame::IconLoad::IconLoad()
{
nsIPrefBranch2* prefBranch = nsContentUtils::GetPrefBranch();
// register observers
for (PRUint32 i = 0; i < NS_ARRAY_LENGTH(kIconLoadPrefs); ++i)
prefBranch->AddObserver(kIconLoadPrefs[i], this, PR_FALSE);
if (prefBranch) {
// register observers
for (PRUint32 i = 0; i < NS_ARRAY_LENGTH(kIconLoadPrefs); ++i)
prefBranch->AddObserver(kIconLoadPrefs[i], this, PR_FALSE);
}
GetPrefs();
}