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

Unified Diff: sync/internal_api/attachments/attachment_downloader_impl.cc

Issue 1885993003: [Sync] Fix a subtle use-after-free in Attachments. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: 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 | tools/valgrind/memcheck/suppressions.txt » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: sync/internal_api/attachments/attachment_downloader_impl.cc
diff --git a/sync/internal_api/attachments/attachment_downloader_impl.cc b/sync/internal_api/attachments/attachment_downloader_impl.cc
index 60a936e22f116aaa88c99ee404678b9bc3c956d5..81f11538f88dcd34d470f955656c9948602d02c1 100644
--- a/sync/internal_api/attachments/attachment_downloader_impl.cc
+++ b/sync/internal_api/attachments/attachment_downloader_impl.cc
@@ -138,8 +138,11 @@ void AttachmentDownloaderImpl::OnGetTokenFailure(
scoped_refptr<base::RefCountedString> null_attachment_data;
ReportResult(*download_state, DOWNLOAD_TRANSIENT_ERROR,
null_attachment_data);
- DCHECK(state_map_.find(download_state->attachment_url) != state_map_.end());
- state_map_.erase(download_state->attachment_url);
+ // Don't delete using the URL directly to avoid an access after free error
+ // due to std::unordered_map's implementation. See crbug.com/603275.
+ auto erase_iter = state_map_.find(download_state->attachment_url);
+ DCHECK(erase_iter != state_map_.end());
+ state_map_.erase(erase_iter);
}
requests_waiting_for_access_token_.clear();
}
« no previous file with comments | « no previous file | tools/valgrind/memcheck/suppressions.txt » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698