Skip to content
This repository was archived by the owner on Sep 30, 2022. It is now read-only.

Commit 1073733

Browse files
authored
Merge pull request #1268 from ggouaillardet/topic/v2.x/group_intersection_malloc
ompi/group: get rid of malloc(0) in ompi_group_intersection(...)
2 parents af5cfc9 + bafa885 commit 1073733

File tree

1 file changed

+6
-4
lines changed

1 file changed

+6
-4
lines changed

ompi/group/group.c

Lines changed: 6 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,7 @@
1616
* Copyright (c) 2012-2013 Inria. All rights reserved.
1717
* Copyright (c) 2013-2015 Los Alamos National Security, LLC. All rights
1818
* reserved.
19-
* Copyright (c) 2015 Research Organization for Information Science
19+
* Copyright (c) 2015-2016 Research Organization for Information Science
2020
* and Technology (RIST). All rights reserved.
2121
* $COPYRIGHT$
2222
*
@@ -453,9 +453,11 @@ int ompi_group_intersection(ompi_group_t* group1,ompi_group_t* group2,
453453

454454
k = 0;
455455
/* allocate the max required memory */
456-
ranks_included = (int *)malloc(group1_pointer->grp_proc_count*(sizeof(int)));
457-
if (NULL == ranks_included) {
458-
return MPI_ERR_NO_MEM;
456+
if (0 < group1_pointer->grp_proc_count) {
457+
ranks_included = (int *)malloc(group1_pointer->grp_proc_count*(sizeof(int)));
458+
if (NULL == ranks_included) {
459+
return MPI_ERR_NO_MEM;
460+
}
459461
}
460462
/* determine the list of included processes for the incl-method */
461463
k = 0;

0 commit comments

Comments
 (0)