Skip to content

Commit 329f558

Browse files
authored
Merge pull request #12039 from ggouaillardet/topic/neighbor_alltoallvw_init
MPI_Neighbor_alltoall{v,w}_init: correctly handle NULL parameters
2 parents 5cb3094 + 01ec480 commit 329f558

File tree

2 files changed

+11
-11
lines changed

2 files changed

+11
-11
lines changed

ompi/mpi/c/neighbor_alltoallv_init.c

Lines changed: 6 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,7 @@
1313
* Copyright (c) 2007 Cisco Systems, Inc. All rights reserved.
1414
* Copyright (c) 2012-2017 Los Alamos National Security, LLC. All rights
1515
* reserved.
16-
* Copyright (c) 2014-2019 Research Organization for Information Science
16+
* Copyright (c) 2014-2023 Research Organization for Information Science
1717
* and Technology (RIST). All rights reserved.
1818
* Copyright (c) 2017 IBM Corporation. All rights reserved.
1919
* $COPYRIGHT$
@@ -102,14 +102,15 @@ int MPI_Neighbor_alltoallv_init(const void *sendbuf, const int sendcounts[], con
102102
} else if (! OMPI_COMM_IS_TOPO(comm)) {
103103
return OMPI_ERRHANDLER_NOHANDLE_INVOKE(MPI_ERR_TOPOLOGY,
104104
FUNC_NAME);
105-
} else if ((NULL == sendcounts) || (NULL == sdispls) ||
106-
(NULL == recvcounts) || (NULL == rdispls) ||
107-
MPI_IN_PLACE == sendbuf || MPI_IN_PLACE == recvbuf) {
108-
return OMPI_ERRHANDLER_INVOKE(comm, MPI_ERR_ARG, FUNC_NAME);
109105
}
110106

111107
err = mca_topo_base_neighbor_count (comm, &indegree, &outdegree);
112108
OMPI_ERRHANDLER_CHECK(err, comm, err, FUNC_NAME);
109+
if (((0 < outdegree) && ((NULL == sendcounts) || (NULL == sdispls))) ||
110+
((0 < indegree) && ((NULL == recvcounts) || (NULL == rdispls))) ||
111+
MPI_IN_PLACE == sendbuf || MPI_IN_PLACE == recvbuf) {
112+
return OMPI_ERRHANDLER_INVOKE(comm, MPI_ERR_ARG, FUNC_NAME);
113+
}
113114
for (i = 0; i < outdegree; ++i) {
114115
OMPI_CHECK_DATATYPE_FOR_SEND(err, sendtype, sendcounts[i]);
115116
OMPI_ERRHANDLER_CHECK(err, comm, err, FUNC_NAME);

ompi/mpi/c/neighbor_alltoallw_init.c

Lines changed: 5 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,7 @@
1313
* Copyright (c) 2007 Cisco Systems, Inc. All rights reserved.
1414
* Copyright (c) 2012-2017 Los Alamos National Security, LLC. All rights
1515
* reserved.
16-
* Copyright (c) 2014-2019 Research Organization for Information Science
16+
* Copyright (c) 2014-2023 Research Organization for Information Science
1717
* and Technology (RIST). All rights reserved.
1818
* Copyright (c) 2017 IBM Corporation. All rights reserved.
1919
* $COPYRIGHT$
@@ -102,14 +102,13 @@ int MPI_Neighbor_alltoallw_init(const void *sendbuf, const int sendcounts[], con
102102
FUNC_NAME);
103103
}
104104

105-
if ((NULL == sendcounts) || (NULL == sdispls) || (NULL == sendtypes) ||
106-
(NULL == recvcounts) || (NULL == rdispls) || (NULL == recvtypes) ||
105+
err = mca_topo_base_neighbor_count (comm, &indegree, &outdegree);
106+
OMPI_ERRHANDLER_CHECK(err, comm, err, FUNC_NAME);
107+
if (((0 < outdegree) && ((NULL == sendcounts) || (NULL == sdispls) || (NULL == sendtypes))) ||
108+
((0 < indegree) && ((NULL == recvcounts) || (NULL == rdispls) || (NULL == recvtypes))) ||
107109
MPI_IN_PLACE == sendbuf || MPI_IN_PLACE == recvbuf) {
108110
return OMPI_ERRHANDLER_INVOKE(comm, MPI_ERR_ARG, FUNC_NAME);
109111
}
110-
111-
err = mca_topo_base_neighbor_count (comm, &indegree, &outdegree);
112-
OMPI_ERRHANDLER_CHECK(err, comm, err, FUNC_NAME);
113112
for (i = 0; i < outdegree; ++i) {
114113
OMPI_CHECK_DATATYPE_FOR_SEND(err, sendtypes[i], sendcounts[i]);
115114
OMPI_ERRHANDLER_CHECK(err, comm, err, FUNC_NAME);

0 commit comments

Comments
 (0)