diff options
author | Pedro Vicente Nunes <pvn@hdfgroup.org> | 2009-04-07 15:05:33 (GMT) |
---|---|---|
committer | Pedro Vicente Nunes <pvn@hdfgroup.org> | 2009-04-07 15:05:33 (GMT) |
commit | fecd6ab5593c4953d8641fe516271d1e75089764 (patch) | |
tree | d1bc73a7f568da8ea994537cb1ddcd625f713198 /hl/src/H5DS.c | |
parent | 1105b86f61e6602e383408cdde9e28f6b4eb1d45 (diff) | |
download | hdf5-fecd6ab5593c4953d8641fe516271d1e75089764.zip hdf5-fecd6ab5593c4953d8641fe516271d1e75089764.tar.gz hdf5-fecd6ab5593c4953d8641fe516271d1e75089764.tar.bz2 |
[svn-r16677] merge 16676 from trunk
#1521 (B2) H5DSdetach_scale memory leak
ISSUE: Purify (Windows Visual Studio 6) complains of a memory leak in H5DSdetach_scale call regarding a H5Aread call (stack is H5A_read, H5T_convert, H5T_conv_vlen, H5T_vlen_seq_mem_write, H5MM_malloc).
SOLUTION: When a scale is detached from a dataset, the variable length structure length field is decreased in one entry. The associated pointer must be reallocated with the new length.
DOCS AND TEST: Nothing added
tested: linux
Diffstat (limited to 'hl/src/H5DS.c')
-rw-r--r-- | hl/src/H5DS.c | 14 |
1 files changed, 11 insertions, 3 deletions
diff --git a/hl/src/H5DS.c b/hl/src/H5DS.c index 83bb1ed..10e552b 100644 --- a/hl/src/H5DS.c +++ b/hl/src/H5DS.c @@ -749,13 +749,21 @@ herr_t H5DSdetach_scale(hid_t did, goto out; /* same object, reset */ - if(oi1.fileno == oi2.fileno && oi1.addr == oi2.addr) { + if(oi1.fileno == oi2.fileno && oi1.addr == oi2.addr) + { + size_t len; + for(jj=j; jj<buf[idx].len-1; jj++) + { ((hobj_ref_t *)buf[idx].p)[jj] = ((hobj_ref_t *)buf[idx].p)[jj+1]; + } + buf[idx].len--; - + len = buf[idx].len; + buf[idx].p = realloc( buf[idx].p, len * sizeof(hobj_ref_t)); + found_ds = 1; - + /* close the dereferenced dataset and break */ if (H5Dclose(dsid_j) < 0) goto out; |