From: Arnaud Giersch Date: Thu, 7 Mar 2019 17:21:39 +0000 (+0100) Subject: Fix null pointer dereference. X-Git-Tag: v3_22~145 X-Git-Url: http://info.iut-bm.univ-fcomte.fr/pub/gitweb/simgrid.git/commitdiff_plain/1b94b2100679d5b4355fccb6d22927efc12ca5bc?ds=sidebyside Fix null pointer dereference. --- diff --git a/src/simix/libsmx.cpp b/src/simix/libsmx.cpp index 16347e9a52..4909007cbc 100644 --- a/src/simix/libsmx.cpp +++ b/src/simix/libsmx.cpp @@ -416,15 +416,13 @@ smx_activity_t simcall_execution_parallel_start(const std::string& name, int hos } xbt_assert(std::isfinite(rate), "rate is not finite!"); - std::vector hosts; + std::vector hosts(host_list, host_list + host_nb); std::vector flops_parallel_amount; std::vector bytes_parallel_amount; - for (int i = 0; i < host_nb; i++) { - hosts.push_back(host_list[i]); - flops_parallel_amount.push_back(flops_amount[i]); - for (int j = 0; j < host_nb; j++) - bytes_parallel_amount.push_back(bytes_amount[i]); - } + if (flops_amount != nullptr) + flops_parallel_amount = std::vector(flops_amount, flops_amount + host_nb); + if (bytes_amount != nullptr) + bytes_parallel_amount = std::vector(bytes_amount, bytes_amount + host_nb * host_nb); return simgrid::simix::simcall([name, hosts, flops_parallel_amount, bytes_parallel_amount, timeout] { return simgrid::kernel::activity::ExecImplPtr(new simgrid::kernel::activity::ExecImpl(std::move(name), "")) ->set_timeout(timeout)