Skip to content

Commit

Permalink
Merge pull request ESMCI#1414 from wkliao/fix_my_proc_list
Browse files Browse the repository at this point in the history
bug fix: allocate my_proc_list after checking component_count
  • Loading branch information
edhartnett authored May 13, 2019
2 parents c84b201 + 82f1b7e commit 21229d9
Showing 1 changed file with 5 additions and 1 deletion.
6 changes: 5 additions & 1 deletion src/clib/pioc.c
Original file line number Diff line number Diff line change
Expand Up @@ -1333,7 +1333,7 @@ int PIOc_init_async(MPI_Comm world, int num_io_procs, int *io_proc_list,
int *iosysidp)
{
int my_rank; /* Rank of this task. */
int *my_proc_list[component_count]; /* Array of arrays of procs for comp components. */
int **my_proc_list; /* Array of arrays of procs for comp components. */
int my_io_proc_list[num_io_procs]; /* List of processors in IO component. */
int mpierr; /* Return code from MPI functions. */
int ret; /* Return code. */
Expand All @@ -1343,6 +1343,8 @@ int PIOc_init_async(MPI_Comm world, int num_io_procs, int *io_proc_list,
(rearranger != PIO_REARR_BOX))
return pio_err(NULL, NULL, PIO_EINVAL, __FILE__, __LINE__);

my_proc_list = (int**) malloc(component_count * sizeof(int*));

/* Turn on the logging system for PIO. */
pio_init_logging();
LOG((1, "PIOc_init_async num_io_procs = %d component_count = %d", num_io_procs,
Expand Down Expand Up @@ -1641,6 +1643,8 @@ int PIOc_init_async(MPI_Comm world, int num_io_procs, int *io_proc_list,
for (int cmp = 0; cmp < component_count; cmp++)
free(my_proc_list[cmp]);

free(my_proc_list);

/* Free MPI groups. */
if ((ret = MPI_Group_free(&io_group)))
return check_mpi(NULL, ret, __FILE__, __LINE__);
Expand Down

0 comments on commit 21229d9

Please sign in to comment.