Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(312)

Unified Diff: chrome/browser/profiles/profile_manager.cc

Issue 65643006: Make a copy before enumerating profiles because the list might change underneath. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: . Created 7 years, 1 month ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
« no previous file with comments | « no previous file | no next file » | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: chrome/browser/profiles/profile_manager.cc
diff --git a/chrome/browser/profiles/profile_manager.cc b/chrome/browser/profiles/profile_manager.cc
index ecd8e5d306fcdf8347e069adae7f063fab121937..94d56c37fd2dd9f1599f01904848188aebd2f8f5 100644
--- a/chrome/browser/profiles/profile_manager.cc
+++ b/chrome/browser/profiles/profile_manager.cc
@@ -397,19 +397,19 @@ std::vector<Profile*> ProfileManager::GetLastOpenedProfiles(
DCHECK(local_state);
std::vector<Profile*> to_return;
- if (local_state->HasPrefPath(prefs::kProfilesLastActive)) {
- const ListValue* profile_list =
- local_state->GetList(prefs::kProfilesLastActive);
- if (profile_list) {
- ListValue::const_iterator it;
- std::string profile;
- for (it = profile_list->begin(); it != profile_list->end(); ++it) {
- if (!(*it)->GetAsString(&profile) || profile.empty()) {
- LOG(WARNING) << "Invalid entry in " << prefs::kProfilesLastActive;
- continue;
- }
- to_return.push_back(GetProfile(user_data_dir.AppendASCII(profile)));
+ if (local_state->HasPrefPath(prefs::kProfilesLastActive) &&
+ local_state->GetList(prefs::kProfilesLastActive)) {
+ // Make a copy because the list might change in the calls to GetProfile.
+ scoped_ptr<base::ListValue> profile_list(
+ local_state->GetList(prefs::kProfilesLastActive)->DeepCopy());
+ base::ListValue::const_iterator it;
+ std::string profile;
+ for (it = profile_list->begin(); it != profile_list->end(); ++it) {
+ if (!(*it)->GetAsString(&profile) || profile.empty()) {
+ LOG(WARNING) << "Invalid entry in " << prefs::kProfilesLastActive;
+ continue;
}
+ to_return.push_back(GetProfile(user_data_dir.AppendASCII(profile)));
}
}
return to_return;
« no previous file with comments | « no previous file | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698