Fix memory leak due to addition of FORMAT check loop

This commit is contained in:
Allen Byrne 2017-12-29 11:53:11 -06:00
parent f5f2c36d98
commit 6d3f7dea86

View File

@ -1360,12 +1360,15 @@ main(void)
unsigned new_format;
int nerrors = 0;
/* Testing setup */
h5_reset();
/*******************************************************************/
/* ENSURE THAT WRITING TO DATASETS AND CREATING GROUPS WORKS */
/*******************************************************************/
/* Test with old & new format groups */
for (new_format = FALSE; new_format <= TRUE; new_format++) {
hid_t my_fapl_id;
/* Testing setup */
h5_reset();
/* Get a VFD-dependent filename */
if ((old_ff_fapl_id = h5_fileaccess()) < 0)
@ -1375,22 +1378,18 @@ main(void)
if (disable_chunk_cache(old_ff_fapl_id) < 0)
TEST_ERROR;
/* Fix up the filename for the VFD */
h5_fixname(FILENAME[0], old_ff_fapl_id, filename, sizeof(filename));
/* Set the FAPL for the type of format */
if (new_format) {
HDputs("\nTesting with new file format:");
/* Copy the file access property list and set the latest file format on it */
if ((new_ff_fapl_id = H5Pcopy(old_ff_fapl_id)) < 0)
TEST_ERROR;
if (H5Pset_libver_bounds(new_ff_fapl_id, H5F_LIBVER_LATEST, H5F_LIBVER_LATEST) < 0)
TEST_ERROR;
/* Fix up the filename for the VFD */
h5_fixname(FILENAME[0], old_ff_fapl_id, filename, sizeof(filename));
/* Test with old & new format groups */
for (new_format = FALSE; new_format <= TRUE; new_format++) {
hid_t my_fapl_id;
/* Set the FAPL for the type of format */
if (new_format) {
HDputs("\nTesting with new file format:");
my_fapl_id = new_ff_fapl_id;
}
else {
@ -1410,13 +1409,14 @@ main(void)
if (H5Fclose(fid) < 0)
TEST_ERROR;
} /* end for */
/* Close FAPLs */
if (H5Pclose(old_ff_fapl_id) < 0)
TEST_ERROR;
if (new_format) {
if (H5Pclose(new_ff_fapl_id) < 0)
TEST_ERROR;
}
/* Restore the default error handler (set in h5_reset()) */
h5_restore_err();
@ -1432,8 +1432,21 @@ main(void)
if ((old_ff_fapl_id = h5_fileaccess()) < 0)
TEST_ERROR;
/* Set the FAPL for the type of format */
if (new_format) {
/* Copy the file access property list and set the latest file format on it */
if ((new_ff_fapl_id = H5Pcopy(old_ff_fapl_id)) < 0)
TEST_ERROR;
if (H5Pset_libver_bounds(new_ff_fapl_id, H5F_LIBVER_LATEST, H5F_LIBVER_LATEST) < 0)
TEST_ERROR;
my_fapl_id = new_ff_fapl_id;
}
else
my_fapl_id = old_ff_fapl_id;
/* Reopen the file for testing data reading */
if ((fid = H5Fopen(filename, H5F_ACC_RDONLY, old_ff_fapl_id)) < 0)
if ((fid = H5Fopen(filename, H5F_ACC_RDONLY, my_fapl_id)) < 0)
TEST_ERROR;
/* Read the data with filters */
@ -1442,6 +1455,14 @@ main(void)
/* Test creating groups using dynamically-loaded plugin filters */
nerrors += (test_opening_groups_using_plugins(fid) < 0 ? 1 : 0);
/* Close FAPLs */
if (H5Pclose(old_ff_fapl_id) < 0)
TEST_ERROR;
if (new_format) {
if (H5Pclose(new_ff_fapl_id) < 0)
TEST_ERROR;
}
/* Restore the default error handler (set in h5_reset()) */
h5_restore_err();
@ -1454,8 +1475,21 @@ main(void)
if ((old_ff_fapl_id = h5_fileaccess()) < 0)
TEST_ERROR;
/* Set the FAPL for the type of format */
if (new_format) {
/* Copy the file access property list and set the latest file format on it */
if ((new_ff_fapl_id = H5Pcopy(old_ff_fapl_id)) < 0)
TEST_ERROR;
if (H5Pset_libver_bounds(new_ff_fapl_id, H5F_LIBVER_LATEST, H5F_LIBVER_LATEST) < 0)
TEST_ERROR;
my_fapl_id = new_ff_fapl_id;
}
else
my_fapl_id = old_ff_fapl_id;
/* Reopen the file for testing data reading */
if ((fid = H5Fopen(filename, H5F_ACC_RDONLY, old_ff_fapl_id)) < 0)
if ((fid = H5Fopen(filename, H5F_ACC_RDONLY, my_fapl_id)) < 0)
TEST_ERROR;
/* When filters are disabled, make sure we can't read data from a
@ -1466,6 +1500,31 @@ main(void)
if (H5Fclose(fid) < 0)
TEST_ERROR;
/*********************/
/* CLEAN UP */
/*********************/
/* Close FAPLs */
if (new_format) {
if (H5Pclose(new_ff_fapl_id) < 0)
TEST_ERROR;
}
else {
/* Restore the default error handler (set in h5_reset()) */
h5_restore_err();
if (H5Pclose(old_ff_fapl_id) < 0)
TEST_ERROR;
}
/* Free up saved arrays */
free_2D_array(&orig_deflate_g);
free_2D_array(&orig_dynlib1_g);
free_2D_array(&orig_dynlib2_g);
free_2D_array(&orig_dynlib4_g);
} /* end for */
h5_cleanup(FILENAME, old_ff_fapl_id);
/************************************/
/* TEST THE FILTER PLUGIN API CALLS */
/************************************/
@ -1473,21 +1532,10 @@ main(void)
/* Test the APIs for access to the filter plugin path table */
nerrors += (test_path_api_calls() < 0 ? 1 : 0);
/*********************/
/* CLEAN UP AND EXIT */
/*********************/
/* Free up saved arrays */
free_2D_array(&orig_deflate_g);
free_2D_array(&orig_dynlib1_g);
free_2D_array(&orig_dynlib2_g);
free_2D_array(&orig_dynlib4_g);
if (nerrors)
TEST_ERROR;
HDprintf("All plugin tests passed.\n");
h5_cleanup(FILENAME, old_ff_fapl_id);
HDexit(EXIT_SUCCESS);