summaryrefslogtreecommitdiffstats
path: root/hl/src/H5DS.c
diff options
context:
space:
mode:
authorPedro Vicente Nunes <pvn@hdfgroup.org>2009-04-07 14:56:08 (GMT)
committerPedro Vicente Nunes <pvn@hdfgroup.org>2009-04-07 14:56:08 (GMT)
commit92bbd705f1fabb4d7ad8527133d26ed4e9bf5df4 (patch)
tree59840c8bcc820fbc56462ca22698034300d1f69c /hl/src/H5DS.c
parentcade98122a510d6d2071e81ffd4c6e31d9374261 (diff)
downloadhdf5-92bbd705f1fabb4d7ad8527133d26ed4e9bf5df4.zip
hdf5-92bbd705f1fabb4d7ad8527133d26ed4e9bf5df4.tar.gz
hdf5-92bbd705f1fabb4d7ad8527133d26ed4e9bf5df4.tar.bz2
[svn-r16676] #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: windows with purify, linux
Diffstat (limited to 'hl/src/H5DS.c')
-rw-r--r--hl/src/H5DS.c14
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;