diff options
author | Igor Gapchuk (GitHub) <41586842+IGapchuk@users.noreply.github.com> | 2020-02-12 19:22:44 +0200 |
---|---|---|
committer | GitHub <noreply@github.com> | 2020-02-12 12:22:44 -0500 |
commit | 656cb05756bbc20625adad8e4b2dcb6f40359352 (patch) | |
tree | c92b069db6d0116745e9dd5899d3550491f6d3ac | |
parent | 9d4a036bb437c1a5a7de4b73425073ea3e0d2987 (diff) | |
download | sdl_core-656cb05756bbc20625adad8e4b2dcb6f40359352.tar.gz |
Fix core crash on accesing the application pointer. (#3194)
* Fix core crash on accesing the application pointer.
The issue will occur when the state controller gets an application
collection from the application manager and tries to apply a functor
to each application.
One of the application's pointers could be uninitialized and the state
controller should check if pointer is valid.
* fixup! Fix core crash on accesing the application pointer.
-rw-r--r-- | src/components/application_manager/include/application_manager/state_controller_impl.h | 15 | ||||
-rw-r--r-- | src/components/application_manager/src/state_controller_impl.cc | 1 |
2 files changed, 9 insertions, 7 deletions
diff --git a/src/components/application_manager/include/application_manager/state_controller_impl.h b/src/components/application_manager/include/application_manager/state_controller_impl.h index 000569e450..c6121f5d1d 100644 --- a/src/components/application_manager/include/application_manager/state_controller_impl.h +++ b/src/components/application_manager/include/application_manager/state_controller_impl.h @@ -152,13 +152,14 @@ class StateControllerImpl : public event_engine::EventObserver, template <typename UnaryFunction> void ForEachApplication(UnaryFunction func) const { - DataAccessor<ApplicationSet> accessor = app_mngr_.applications(); - ApplicationSet::iterator it = accessor.GetData().begin(); - for (; it != accessor.GetData().end(); ++it) { - ApplicationConstSharedPtr const_app = *it; - if (const_app) { - func(app_mngr_.application(const_app->app_id())); - } + ApplicationSet applications; + { + DataAccessor<ApplicationSet> accessor = app_mngr_.applications(); + applications = accessor.GetData(); + } + + for (const auto& app : applications) { + func(app); } } diff --git a/src/components/application_manager/src/state_controller_impl.cc b/src/components/application_manager/src/state_controller_impl.cc index 1bf4c2bf66..b07a5bcc13 100644 --- a/src/components/application_manager/src/state_controller_impl.cc +++ b/src/components/application_manager/src/state_controller_impl.cc @@ -976,6 +976,7 @@ int64_t StateControllerImpl::RequestHMIStateChange( void StateControllerImpl::ApplyPostponedStateForApp(ApplicationSharedPtr app) { LOG4CXX_AUTO_TRACE(logger_); + DCHECK_OR_RETURN_VOID(app); const WindowIds window_ids = app->GetWindowIds(); for (const auto& window_id : window_ids) { |