Index: chrome/browser/translate/translate_prefs.cc |
diff --git a/chrome/browser/translate/translate_prefs.cc b/chrome/browser/translate/translate_prefs.cc |
index 11c2f49547f9d99d8cd294a639715503f6f28515..8ec9736ee8d82300cf31518062b42bf20d22ba3b 100644 |
--- a/chrome/browser/translate/translate_prefs.cc |
+++ b/chrome/browser/translate/translate_prefs.cc |
@@ -324,22 +324,23 @@ void TranslatePrefs::MigrateUserPrefs(PrefService* user_prefs) { |
// keep auto-translated. |
DictionaryPrefUpdate update(user_prefs, kPrefTranslateWhitelists); |
DictionaryValue* dict = update.Get(); |
- if (!dict || dict->empty()) |
- return; |
- DictionaryValue::Iterator iter(*dict); |
- while (!iter.IsAtEnd()) { |
- const ListValue* list = NULL; |
- if (!iter.value().GetAsList(&list) || !list) |
- break; // Dictionary has either been migrated or new format. |
- std::string key = iter.key(); |
- // Advance the iterator before removing the current element. |
- iter.Advance(); |
- std::string target_lang; |
- if (list->empty() || !list->GetString(list->GetSize() - 1, &target_lang) || |
- target_lang.empty()) { |
- dict->Remove(key, NULL); |
- } else { |
- dict->SetString(key, target_lang); |
+ if (dict && !dict->empty()) { |
+ DictionaryValue::Iterator iter(*dict); |
+ while (!iter.IsAtEnd()) { |
+ const ListValue* list = NULL; |
+ if (!iter.value().GetAsList(&list) || !list) |
+ break; // Dictionary has either been migrated or new format. |
+ std::string key = iter.key(); |
+ // Advance the iterator before removing the current element. |
+ iter.Advance(); |
+ std::string target_lang; |
+ if (list->empty() || |
+ !list->GetString(list->GetSize() - 1, &target_lang) || |
+ target_lang.empty()) { |
+ dict->Remove(key, NULL); |
+ } else { |
+ dict->SetString(key, target_lang); |
+ } |
} |
} |