From 5f7f104edbeb1ff7362303fd60eeb7565829733e Mon Sep 17 00:00:00 2001 From: Martin Quinson Date: Sat, 17 Aug 2019 23:07:21 +0200 Subject: [PATCH] PMPI_Cart_create: check that each dim is positive --- src/smpi/bindings/smpi_pmpi_topo.cpp | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/src/smpi/bindings/smpi_pmpi_topo.cpp b/src/smpi/bindings/smpi_pmpi_topo.cpp index 37c62ef03f..c0cd8f0d58 100644 --- a/src/smpi/bindings/smpi_pmpi_topo.cpp +++ b/src/smpi/bindings/smpi_pmpi_topo.cpp @@ -19,7 +19,11 @@ int PMPI_Cart_create(MPI_Comm comm_old, int ndims, const int* dims, const int* p return MPI_ERR_COMM; } else if (ndims < 0 || (ndims > 0 && (dims == nullptr || periodic == nullptr)) || comm_cart == nullptr) { return MPI_ERR_ARG; - } else{ + } else { + for (int i = 0; i < ndims; i++) + if (dims[i] < 0) + return MPI_ERR_ARG; + simgrid::smpi::Topo_Cart* topo = new simgrid::smpi::Topo_Cart(comm_old, ndims, dims, periodic, reorder, comm_cart); if (*comm_cart == MPI_COMM_NULL) { delete topo; -- 2.20.1