summaryrefslogtreecommitdiffstats
path: root/tools/h5repack/h5repack_refs.c
diff options
context:
space:
mode:
authorJonathan Kim <jkm@hdfgroup.org>2012-01-09 21:24:50 (GMT)
committerJonathan Kim <jkm@hdfgroup.org>2012-01-09 21:24:50 (GMT)
commit00b9f24d9b161817876921a8bd983ed1d148def1 (patch)
treec57416b820a40440905528abe5b3b62c51495f1b /tools/h5repack/h5repack_refs.c
parente0db7c89228e73cd3e30604f4987ee3146a8380f (diff)
downloadhdf5-00b9f24d9b161817876921a8bd983ed1d148def1.zip
hdf5-00b9f24d9b161817876921a8bd983ed1d148def1.tar.gz
hdf5-00b9f24d9b161817876921a8bd983ed1d148def1.tar.bz2
[svn-r21869] 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. Tested: jam (linux32-LE), koala (linux64-LE), heiwa (linuxppc64-BE), tejeda (mac32-LE), linew (solaris-BE), Windows (32-LE), 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 f4aa8ff..5690091 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);