diff options
author | Dana Robinson <derobins@hdfgroup.org> | 2016-11-23 18:58:12 (GMT) |
---|---|---|
committer | Dana Robinson <derobins@hdfgroup.org> | 2016-11-23 18:58:12 (GMT) |
commit | b0321f7e7d45a2c3ad45f26c3ea1c6bf106d613a (patch) | |
tree | 40c5562d52fdc779c0a939e14b4b0599f42b452a /test | |
parent | 4bb51bbbaa9bf8b1064b73b66b10bc4ac1c601cf (diff) | |
parent | e2863ca880a6983558d3ba3e5219164a57287f04 (diff) | |
download | hdf5-b0321f7e7d45a2c3ad45f26c3ea1c6bf106d613a.zip hdf5-b0321f7e7d45a2c3ad45f26c3ea1c6bf106d613a.tar.gz hdf5-b0321f7e7d45a2c3ad45f26c3ea1c6bf106d613a.tar.bz2 |
Merge pull request #170 in HDFFV/hdf5 from ~DEROBINS/hdf5_der:develop_memfix to develop
Fixed a few memory issues in the tests.
* commit 'e2863ca880a6983558d3ba3e5219164a57287f04':
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.c | 1 | ||||
-rw-r--r-- | test/h5test.c | 33 | ||||
-rw-r--r-- | test/vfd.c | 2 |
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() */ @@ -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. */ |