[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
This commit is contained in:
Pedro Vicente Nunes 2009-04-07 09:56:08 -05:00
parent cade98122a
commit 92bbd705f1

View File

@ -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;