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

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

Issue 1838083006: Fix a use-after-free error in WaitOrCountBookmarks (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Fix errors in code. Created 4 years, 8 months 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 | chrome/browser/profiles/profile_statistics_unittest.cc » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: chrome/browser/profiles/profile_statistics_aggregator.cc
diff --git a/chrome/browser/profiles/profile_statistics_aggregator.cc b/chrome/browser/profiles/profile_statistics_aggregator.cc
index 1335d0149c96c832cc9bdd06db01159cd962be60..519dcc79e57e614a513e81bc2221b79ff2222d37 100644
--- a/chrome/browser/profiles/profile_statistics_aggregator.cc
+++ b/chrome/browser/profiles/profile_statistics_aggregator.cc
@@ -197,7 +197,10 @@ void ProfileStatisticsAggregator::WaitOrCountBookmarks() {
if (bookmark_model) {
if (bookmark_model->loaded()) {
CountBookmarks(bookmark_model);
- } else {
+ } else if (!bookmark_model_helper_) {
+ // If |bookmark_model_helper_| is not null, it means a previous bookmark
+ // counting task still waiting for the bookmark model to load. Do nothing
+ // and continue to use the old |bookmark_model_helper_| in this case.
AddRef();
bookmark_model_helper_.reset(new BookmarkModelHelper(this));
bookmark_model->AddObserver(bookmark_model_helper_.get());
« no previous file with comments | « no previous file | chrome/browser/profiles/profile_statistics_unittest.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698