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

Unified Diff: components/ntp_snippets/remote/ntp_snippets_fetcher.cc

Issue 2485933003: Fixes an invalidated pointer access in NTPSnipppetsFetcher. (Closed)
Patch Set: adressed other comments from https://codereview.chromium.org/2473483006/ Created 4 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
Index: components/ntp_snippets/remote/ntp_snippets_fetcher.cc
diff --git a/components/ntp_snippets/remote/ntp_snippets_fetcher.cc b/components/ntp_snippets/remote/ntp_snippets_fetcher.cc
index 84920e192ca1180917115bc5de9e72eaedfbb8cf..2ea5b5a6a41d87c3ee8379e63ac364b9473b83b6 100644
--- a/components/ntp_snippets/remote/ntp_snippets_fetcher.cc
+++ b/components/ntp_snippets/remote/ntp_snippets_fetcher.cc
@@ -774,8 +774,9 @@ void NTPSnippetsFetcher::FilterCategories(FetchedCategoriesVector* categories) {
categories->clear();
return;
}
- categories->erase(categories->begin(), category_it);
- categories->erase(category_it + 1, categories->end());
+ FetchedCategory category = std::move(*category_it);
+ categories->clear();
+ categories->emplace_back(std::move(category));
}
void NTPSnippetsFetcher::FetchFinished(
@@ -785,9 +786,9 @@ void NTPSnippetsFetcher::FetchFinished(
DCHECK(result == FetchResult::SUCCESS || !fetched_categories);
last_status_ = FetchResultToString(result) + extra_message;
- // TODO(fhorschig): Filter (un)wanted categories by modifying fetch request.
- // As soon as backends support the parameter, there is no reason to overfetch
- // and filter here.
+ // Filter out unwanted categories if necessary.
+ // TODO(fhorschig): As soon as the server supports filtering by
+ // that instead of over-fetching and filtering here.
if (fetched_categories.has_value())
FilterCategories(&fetched_categories.value());

Powered by Google App Engine
This is Rietveld 408576698