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

Unified Diff: chrome/browser/sync/glue/synced_session_tracker.cc

Issue 495593003: Avoid memory corruption in sessions sync (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Created 6 years, 4 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/sync/sessions/sessions_sync_manager.h » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: chrome/browser/sync/glue/synced_session_tracker.cc
diff --git a/chrome/browser/sync/glue/synced_session_tracker.cc b/chrome/browser/sync/glue/synced_session_tracker.cc
index d5cad409f4c2cd08ce626f8430744b21f333bdff..57485bea1672c6f32b7417c26f218ca38bfc725b 100644
--- a/chrome/browser/sync/glue/synced_session_tracker.cc
+++ b/chrome/browser/sync/glue/synced_session_tracker.cc
@@ -286,8 +286,20 @@ void SyncedSessionTracker::PutTabInWindow(const std::string& session_tag,
// collected eventually.
SessionTab* tab_ptr = GetTabImpl(
session_tag, tab_id, TabNodePool::kInvalidTabNodeID);
+
+ // It's up to the caller to ensure this never happens. Tabs should not
+ // belong to more than one window or appear twice within the same window.
+ //
+ // If this condition were violated, we would double-free during shutdown.
+ // That could cause all sorts of hard to diagnose crashes, possibly in code
+ // far away from here. We crash early to avoid this.
+ //
+ // See http://crbug.com/360822.
+ CHECK(!synced_tab_map_[session_tag][tab_id].owned);
+
unmapped_tabs_.erase(tab_ptr);
synced_tab_map_[session_tag][tab_id].owned = true;
+
tab_ptr->window_id.set_id(window_id);
DVLOG(1) << " - tab " << tab_id << " added to window "<< window_id;
DCHECK(GetSession(session_tag)->windows.find(window_id) !=
« no previous file with comments | « no previous file | chrome/browser/sync/sessions/sessions_sync_manager.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698