Commit f560b8a2 authored by Reid Kleckner's avatar Reid Kleckner Committed by Commit Bot

Fix use-after-scope in ash window controller

The temporary base::Optional<PersistentWindowInfo> object is destroyed
at the end of the full expression in this statement:
  const auto& persistent_window_info =
    *window_state->persistent_window_info();
Avoid the lifetime issue by making a copy of the small struct.

This bug was found by ASan after a clang change to more accurately track
the lifetime of temporaries like these.

TBR=afakhry@chromium.org

Bug: 869067
Change-Id: Ibb4cd6761ec29fc09cd42c75b8d7bb13844f5352
Reviewed-on: https://chromium-review.googlesource.com/1157256Reviewed-by: default avatarReid Kleckner <rnk@chromium.org>
Commit-Queue: Reid Kleckner <rnk@chromium.org>
Cr-Commit-Position: refs/heads/master@{#579579}
parent f761c230
...@@ -96,7 +96,7 @@ void PersistentWindowController::MaybeRestorePersistentWindowBounds() { ...@@ -96,7 +96,7 @@ void PersistentWindowController::MaybeRestorePersistentWindowBounds() {
wm::WindowState* window_state = wm::GetWindowState(window); wm::WindowState* window_state = wm::GetWindowState(window);
if (!window_state->persistent_window_info()) if (!window_state->persistent_window_info())
continue; continue;
const auto& persistent_window_info = PersistentWindowInfo persistent_window_info =
*window_state->persistent_window_info(); *window_state->persistent_window_info();
const int64_t persistent_display_id = persistent_window_info.display_id; const int64_t persistent_display_id = persistent_window_info.display_id;
if (persistent_display_id == screen->GetDisplayNearestWindow(window).id()) if (persistent_display_id == screen->GetDisplayNearestWindow(window).id())
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment