From fbda37798d5a49e81102b576b9bad0c72c1d2f9e Mon Sep 17 00:00:00 2001 From: Arnaud Giersch Date: Wed, 6 Feb 2019 17:06:23 +0100 Subject: [PATCH] Fix null pointer dereference spotted by scan-build. --- src/simix/smx_host.cpp | 15 ++++++++------- 1 file changed, 8 insertions(+), 7 deletions(-) diff --git a/src/simix/smx_host.cpp b/src/simix/smx_host.cpp index 19d3516ab6..8de7c6aefa 100644 --- a/src/simix/smx_host.cpp +++ b/src/simix/smx_host.cpp @@ -39,10 +39,10 @@ simgrid::kernel::activity::ExecImplPtr SIMIX_execution_start(std::string name, s simgrid::kernel::activity::ExecImplPtr exec = simgrid::kernel::activity::ExecImplPtr( new simgrid::kernel::activity::ExecImpl(name, category, /*timeout_detector*/ nullptr, host)); - - exec->surf_action_ = surf_action; - exec->surf_action_->set_data(exec.get()); - + if (surf_action != nullptr) { + exec->surf_action_ = surf_action; + exec->surf_action_->set_data(exec.get()); + } XBT_DEBUG("Create execute synchro %p: %s", exec.get(), exec->name_.c_str()); simgrid::kernel::activity::ExecImpl::on_creation(exec); @@ -73,9 +73,10 @@ simgrid::kernel::activity::ExecImplPtr SIMIX_execution_parallel_start(std::strin simgrid::kernel::activity::ExecImplPtr exec = simgrid::kernel::activity::ExecImplPtr( new simgrid::kernel::activity::ExecImpl(name, "", timeout_detector, nullptr)); - exec->surf_action_ = surf_action; - exec->surf_action_->set_data(exec.get()); - + if (surf_action != nullptr) { + exec->surf_action_ = surf_action; + exec->surf_action_->set_data(exec.get()); + } XBT_DEBUG("Create parallel execute synchro %p", exec.get()); return exec; -- 2.20.1