summaryrefslogtreecommitdiffstats
path: root/tools/h5repack/h5repack_refs.c
diff options
context:
space:
mode:
authorJonathan Kim <jkm@hdfgroup.org>2012-01-10 16:23:38 (GMT)
committerJonathan Kim <jkm@hdfgroup.org>2012-01-10 16:23:38 (GMT)
commit5540ecb72d231bbd8800195fd7924b05612017c2 (patch)
tree8710553d25dd4b2ec32090f7e06ac3b8c7b9f6df /tools/h5repack/h5repack_refs.c
parentda199c11f4d06e253ba0970c6e9f09be732ae33b (diff)
downloadhdf5-5540ecb72d231bbd8800195fd7924b05612017c2.zip
hdf5-5540ecb72d231bbd8800195fd7924b05612017c2.tar.gz
hdf5-5540ecb72d231bbd8800195fd7924b05612017c2.tar.bz2
[svn-r21870] Purpose:
Fix for HDFFV-7840 h5repack: memory leak over one of the h5diff test file Description: Turned out that there were two causes of memory leaks. 1. for handling variable length string in attribute. 2. for handling compound type with non-reference members. The first issue is fixed in copy_attr() which is updated to use h5tools_detect_vlen to take care of vlen string as well as vlen data. The second is fixed in copy_refs_attr() of compound handling code. Merged from HDF5 trunk r21869. Tested: jam (linux32-LE), koala (linux64-LE), heiwa (linuxppc64-BE), tejeda (mac32-LE), linew (solaris-BE), Windows (32-LE cmake), Cmake (jam)
Diffstat (limited to 'tools/h5repack/h5repack_refs.c')
-rw-r--r--tools/h5repack/h5repack_refs.c17
1 files changed, 17 insertions, 0 deletions
diff --git a/tools/h5repack/h5repack_refs.c b/tools/h5repack/h5repack_refs.c
index c6753c1..f7103ad 100644
--- a/tools/h5repack/h5repack_refs.c
+++ b/tools/h5repack/h5repack_refs.c
@@ -533,6 +533,23 @@ static int copy_refs_attr(hid_t loc_in,
}
H5Tclose(mtid);
}
+
+ /* if don't contain reference type, free malloc for continue
+ * and malloc again later */
+ if (!ref_comp_field_n)
+ {
+ if (ref_comp_index)
+ {
+ HDfree(ref_comp_index);
+ ref_comp_index = NULL;
+ }
+
+ if (ref_comp_size)
+ {
+ HDfree(ref_comp_size);
+ ref_comp_size = NULL;
+ }
+ }
}
is_ref_comp = (ref_comp_field_n > 0);