[sessionmgr] Fix GetStoryInfo() crash.
It is possible that StoryProvider::GetStoryInfo() returns a nullptr
StoryInfoPtr, so we cannot unconditionally dereference it.
TESTED=the test case added to session_shell_test in https://fuchsia-review.googlesource.com/c/peridot/+/232386
crashes without this fix; with it it passes.
Change-Id: Id32623a8e4402a3e74578eabc8a66561be53b122
diff --git a/bin/sessionmgr/story_runner/story_controller_impl.cc b/bin/sessionmgr/story_runner/story_controller_impl.cc
index 725ac91..113d654 100644
--- a/bin/sessionmgr/story_runner/story_controller_impl.cc
+++ b/bin/sessionmgr/story_runner/story_controller_impl.cc
@@ -1383,7 +1383,11 @@
// may have been deleted when GetStoryInfo returned if there was a
// Delete operation in the queue before GetStoryInfo().
[state = state_, callback](fuchsia::modular::StoryInfoPtr story_info) {
- callback(std::move(*story_info), state);
+ if (story_info) {
+ callback(std::move(*story_info), state);
+ } else {
+ callback(fuchsia::modular::StoryInfo(), state);
+ }
});
}));
}