From 82f1b7e3afaa4c7cd8f43494f2fd536db5fbc96b Mon Sep 17 00:00:00 2001 From: Wei-keng Liao Date: Sun, 12 May 2019 13:05:03 -0500 Subject: [PATCH] bug fix: allocate my_proc_list after checking component_count --- src/clib/pioc.c | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/src/clib/pioc.c b/src/clib/pioc.c index 63462c5ff5b..f9db2c1d8c9 100644 --- a/src/clib/pioc.c +++ b/src/clib/pioc.c @@ -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. */ @@ -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, @@ -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__);