Skip to content

Commit

Permalink
Fix memory corruption in 'MPI I/O FAPL preserve' test (HDFGroup#3806)
Browse files Browse the repository at this point in the history
  • Loading branch information
jhendersonHDF committed Dec 7, 2023
1 parent 7a73793 commit e120618
Showing 1 changed file with 22 additions and 22 deletions.
44 changes: 22 additions & 22 deletions testpar/t_file.c
Original file line number Diff line number Diff line change
Expand Up @@ -1128,28 +1128,27 @@ test_evict_on_close_parallel_unsupp(void)
void
test_fapl_preserve_hints(void)
{
hid_t fid = H5I_INVALID_HID; /* HDF5 file ID */
hid_t fapl_id = H5I_INVALID_HID; /* File access plist */
const char *filename;

int nkeys_used;
bool same = false;

MPI_Info info = MPI_INFO_NULL;
const char *key = "hdf_info_fapl";
const char *value = "xyz";

MPI_Info info_used = MPI_INFO_NULL;
int flag = -1;
char value_used[20];
char key_used[20];

int i;
herr_t ret; /* Generic return value */
int mpi_ret; /* MPI return value */
const char *key = "hdf_info_fapl";
const char *value = "xyz";
MPI_Info info_used = MPI_INFO_NULL;
MPI_Info info = MPI_INFO_NULL;
hid_t fid = H5I_INVALID_HID; /* HDF5 file ID */
hid_t fapl_id = H5I_INVALID_HID; /* File access plist */
char key_used[MPI_MAX_INFO_KEY + 1];
char *value_used = NULL;
bool same = false;
int flag = -1;
int nkeys_used;
int i;
int mpi_ret; /* MPI return value */
herr_t ret; /* Generic return value */

filename = (const char *)GetTestParameters();

value_used = malloc(MPI_MAX_INFO_VAL + 1);
VRFY(value_used, "malloc succeeded");

/* set up MPI parameters */
mpi_ret = MPI_Info_create(&info);
VRFY((mpi_ret >= 0), "MPI_Info_create succeeded");
Expand Down Expand Up @@ -1184,16 +1183,15 @@ test_fapl_preserve_hints(void)
for (i = 0; i < nkeys_used; i++) {

/* Memset the buffers to zero */
memset(key_used, 0, 20);
memset(value_used, 0, 20);
memset(key_used, 0, MPI_MAX_INFO_KEY + 1);
memset(value_used, 0, MPI_MAX_INFO_VAL + 1);

/* Get the nth key */
mpi_ret = MPI_Info_get_nthkey(info_used, i, key_used);
VRFY((mpi_ret == MPI_SUCCESS), "MPI_Info_get_nthkey succeeded");

if (!strcmp(key_used, key)) {

mpi_ret = MPI_Info_get(info_used, key_used, 20, value_used, &flag);
mpi_ret = MPI_Info_get(info_used, key_used, MPI_MAX_INFO_VAL, value_used, &flag);
VRFY((mpi_ret == MPI_SUCCESS), "MPI_Info_get succeeded");

if (!strcmp(value_used, value)) {
Expand All @@ -1220,4 +1218,6 @@ test_fapl_preserve_hints(void)
mpi_ret = MPI_Info_free(&info_used);
VRFY((mpi_ret >= 0), "MPI_Info_free succeeded");

free(value_used);

} /* end test_fapl_preserve_hints() */

0 comments on commit e120618

Please sign in to comment.