summaryrefslogtreecommitdiffstats
path: root/test
diff options
context:
space:
mode:
authorDana Robinson <derobins@hdfgroup.org>2016-11-23 01:55:03 (GMT)
committerDana Robinson <derobins@hdfgroup.org>2016-11-23 01:55:03 (GMT)
commite2863ca880a6983558d3ba3e5219164a57287f04 (patch)
tree26d4ce5f062ab8ef24b4d70447648f007897110f /test
parentfff898558e3c828070abe81b4147bd959ed37ccb (diff)
downloadhdf5-e2863ca880a6983558d3ba3e5219164a57287f04.zip
hdf5-e2863ca880a6983558d3ba3e5219164a57287f04.tar.gz
hdf5-e2863ca880a6983558d3ba3e5219164a57287f04.tar.bz2
Fixed a few memory problems in test/cache_logging.c and
test/h5test.c (which show up in test/vfd.c).
Diffstat (limited to 'test')
-rw-r--r--test/cache_logging.c1
-rw-r--r--test/h5test.c33
-rw-r--r--test/vfd.c2
3 files changed, 24 insertions, 12 deletions
diff --git a/test/cache_logging.c b/test/cache_logging.c
index a5e399c..9190a8a 100644
--- a/test/cache_logging.c
+++ b/test/cache_logging.c
@@ -132,6 +132,7 @@ test_logging_api(void)
TEST_ERROR;
/* Clean up */
+ HDfree(location);
if(H5Fclose(fid) < 0)
TEST_ERROR;
diff --git a/test/h5test.c b/test/h5test.c
index c126da8..f85e96c 100644
--- a/test/h5test.c
+++ b/test/h5test.c
@@ -1584,32 +1584,43 @@ h5_make_local_copy(const char *origfilename, const char *local_copy_name)
{
int fd_old = (-1), fd_new = (-1); /* File descriptors for copying data */
ssize_t nread; /* Number of bytes read in */
- void *buf; /* Buffer for copying data */
- const char *filename = H5_get_srcdir_filename(origfilename);; /* Get the test file name to copy */
+ void *buf = NULL; /* Buffer for copying data */
+ const char *filename = H5_get_srcdir_filename(origfilename); /* Get the test file name to copy */
/* Allocate copy buffer */
- if(NULL == (buf = HDmalloc(READ_BUF_SIZE)))
- return -1;
+ if(NULL == (buf = HDcalloc((size_t)1, (size_t)READ_BUF_SIZE)))
+ goto error;
/* Copy old file into temporary file */
if((fd_old = HDopen(filename, O_RDONLY, 0666)) < 0)
- return -1;
+ goto error;
if((fd_new = HDopen(local_copy_name, O_RDWR|O_CREAT|O_TRUNC, 0666)) < 0)
- return -1;
+ goto error;
/* Copy data */
while((nread = HDread(fd_old, buf, (size_t)READ_BUF_SIZE)) > 0)
if(HDwrite(fd_new, buf, (size_t)nread) < 0)
- return -1;
+ goto error;
+ /* Close files */
+ if(HDclose(fd_old) < 0)
+ goto error;
+ if(HDclose(fd_new) < 0)
+ goto error;
+
/* Release memory */
HDfree(buf);
- /* Close files */
- if(HDclose(fd_old) < 0) return -1;
- if(HDclose(fd_new) < 0) return -1;
-
return 0;
+
+error:
+ /* ignore return values since we're already noted the problem */
+ if(fd_old > 0)
+ HDclose(fd_old);
+ if(fd_new > 0)
+ HDclose(fd_new);
+ HDfree(buf);
+ return -1;
} /* end h5_make_local_copy() */
diff --git a/test/vfd.c b/test/vfd.c
index c19e0d0..a215264 100644
--- a/test/vfd.c
+++ b/test/vfd.c
@@ -997,7 +997,7 @@ test_family_compat(void)
counter++;
HDsnprintf(newname_individual, sizeof(newname_individual), newname, counter);
HDsnprintf(pathname_individual, sizeof(pathname_individual), pathname, counter);
- }
+ } /* end while */
/* Make sure we can open the file. Use the read and write mode to flush the
* superblock. */