From: Arnaud Giersch Date: Wed, 6 Feb 2019 16:06:23 +0000 (+0100) Subject: Fix null pointer dereference spotted by scan-build. X-Git-Tag: v3_22~385 X-Git-Url: http://info.iut-bm.univ-fcomte.fr/pub/gitweb/simgrid.git/commitdiff_plain/fbda37798d5a49e81102b576b9bad0c72c1d2f9e Fix null pointer dereference spotted by scan-build. --- 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;