Commit 24297525 authored by nancy's avatar nancy Committed by Commit Bot

Add the index checking for ash::ShelfModel items.

AppServiceAppWindowCrostiniTracker::OnAppLaunchRequested might be called
when the window is not visible yet, so there is no shelf item yet in
ash::ShelfModel items. model->ItemIndexByAppID(app_id) might return -1.

So adding a checking for -1 (index < 0) to avoid system crash.

BUG=1072870

Change-Id: I26aa2c2ba4fa7cf73af140792be94632a6953b06
Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/2157438
Commit-Queue: Nancy Wang <nancylingwang@chromium.org>
Reviewed-by: default avatarXiyuan Xia <xiyuan@chromium.org>
Cr-Commit-Position: refs/heads/master@{#761025}
parent 3cb9d56a
......@@ -183,12 +183,13 @@ void AppServiceAppWindowCrostiniTracker::OnAppLaunchRequested(
// currently has open.
activation_permissions_.clear();
ash::ShelfModel* model = app_service_controller_->owner()->shelf_model();
if (model->ItemIndexByAppID(app_id) >=
static_cast<int>(model->items().size()))
int index = model->ItemIndexByAppID(app_id);
if (index >= static_cast<int>(model->items().size()) || index < 0)
return;
AppWindowLauncherItemController* launcher_item_controller =
model->GetAppWindowLauncherItemController(
model->items()[model->ItemIndexByAppID(app_id)].id);
model->GetAppWindowLauncherItemController(model->items()[index].id);
// Apps run for the first time won't have a launcher controller yet, return
// early because they won't have windows either so permissions aren't
// necessary.
......
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