From c507554935e3c793dd810e3a11cd32b39934fd74 Mon Sep 17 00:00:00 2001 From: Allen Byrne Date: Thu, 5 Jan 2017 08:58:58 -0600 Subject: Clean up valgrind memory leak --- tools/test/misc/clear_open_chk.c | 30 ++++++++++++++++-------------- 1 file changed, 16 insertions(+), 14 deletions(-) diff --git a/tools/test/misc/clear_open_chk.c b/tools/test/misc/clear_open_chk.c index f3e6ba3..67b5634 100644 --- a/tools/test/misc/clear_open_chk.c +++ b/tools/test/misc/clear_open_chk.c @@ -27,28 +27,28 @@ usage(void) } /* usage() */ /*------------------------------------------------------------------------- - * Function: main + * Function: main * - * Purpose: To open the file which has zero or nonzero status_flags in - * the superblock. + * Purpose: To open the file which has zero or nonzero status_flags in + * the superblock. * - * Return: 0 on success - * 1 on failure + * Return: 0 on success + * 1 on failure * - * Programmer: Vailin Choi; July 2013 + * Programmer: Vailin Choi; July 2013 * *------------------------------------------------------------------------- */ int main(int argc, char *argv[]) { - char *fname; /* The HDF5 file name */ - hid_t fid; /* File ID */ + char *fname; /* The HDF5 file name */ + hid_t fid; /* File ID */ /* Check the # of arguments */ if(argc != 2) { - usage(); - return(EXIT_FAILURE); + usage(); + return(EXIT_FAILURE); } /* Get the file name */ @@ -56,14 +56,16 @@ main(int argc, char *argv[]) /* Try opening the file */ if((fid = h5tools_fopen(fname, H5F_ACC_RDONLY, H5P_DEFAULT, NULL, NULL, (size_t)0)) < 0) { - HDfprintf(stderr, "clear_open_chk: unable to open the file\n"); - return EXIT_FAILURE; + HDfprintf(stderr, "clear_open_chk: unable to open the file\n"); + HDfree(fname); + return EXIT_FAILURE; } + HDfree(fname); /* Close the file */ if(H5Fclose(fid) < 0) { - HDfprintf(stderr, "clear_open_chk: cannot close the file\n"); - return EXIT_FAILURE; + HDfprintf(stderr, "clear_open_chk: cannot close the file\n"); + return EXIT_FAILURE; } /* Return success */ -- cgit v0.12