summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorvchoi-hdfgroup <55293060+vchoi-hdfgroup@users.noreply.github.com>2023-04-14 22:15:56 (GMT)
committerGitHub <noreply@github.com>2023-04-14 22:15:56 (GMT)
commitc23b3482214e3844b05bb4fd377558b3a4d2f1b9 (patch)
tree3691e0695b9ef55161c76cf5f43ffaf24d6856af
parent16bb8809941771a1f3ca9a5a19d1084f32c62a5f (diff)
downloadhdf5-c23b3482214e3844b05bb4fd377558b3a4d2f1b9.zip
hdf5-c23b3482214e3844b05bb4fd377558b3a4d2f1b9.tar.gz
hdf5-c23b3482214e3844b05bb4fd377558b3a4d2f1b9.tar.bz2
Fix for github issue #2599: (#2665) (#2736)
As indicated in the description, memory leak is detected when running "./h5dump pov". The problem is: when calling H5O__add_cont_msg() from H5O__chunk_deserialize(), memory is allocated for cont_msg_info->msgs. Eventually, when the library tries to load the continuation message via H5AC_protect() in H5O_protect(), error is encountered due to illegal info in the continuation message. Due to the error, H5O_protect() exits but the memory allocated for cont_msg_info->msgs is not freed. When we figure out how to handle fuzzed files that we didn't generate, a test needs to be added to run h5dump with the provided "pov" file.
-rw-r--r--release_docs/RELEASE.txt16
-rw-r--r--src/H5Oint.c7
2 files changed, 20 insertions, 3 deletions
diff --git a/release_docs/RELEASE.txt b/release_docs/RELEASE.txt
index dabd21b..a8b1dc7 100644
--- a/release_docs/RELEASE.txt
+++ b/release_docs/RELEASE.txt
@@ -118,8 +118,20 @@ Bug Fixes since HDF5-1.10.10 release
===================================
Library
-------
- -
-
+
+ - Memory leak
+
+ Memory leak was detected when running h5dump with "pov". The memory was allocated
+ via H5FL__malloc() in hdf5/src/H5FL.c
+
+ The fuzzed file "pov" was an HDF5 file containing an illegal continuation message.
+ When deserializing the object header chunks for the file, memory is allocated for the
+ array of continuation messages (cont_msg_info->msgs) in continuation message info struct.
+ As error is encountered in loading the illegal message, the memory allocated for
+ cont_msg_info->msgs needs to be freed.
+
+ (VC - 2023/04/11 GH-2599)
+
Java Library
------------
diff --git a/src/H5Oint.c b/src/H5Oint.c
index 7dc03d4..7986509 100644
--- a/src/H5Oint.c
+++ b/src/H5Oint.c
@@ -1153,9 +1153,14 @@ H5O_protect(const H5O_loc_t *loc, unsigned prot_flags, hbool_t pin_all_chunks)
ret_value = oh;
done:
- if (ret_value == NULL && oh)
+ if (ret_value == NULL && oh) {
+ /* Release any continuation messages built up */
+ if (cont_msg_info.msgs)
+ cont_msg_info.msgs = (H5O_cont_t *)H5FL_SEQ_FREE(H5O_cont_t, cont_msg_info.msgs);
+
if (H5O_unprotect(loc, oh, H5AC__NO_FLAGS_SET) < 0)
HDONE_ERROR(H5E_OHDR, H5E_CANTUNPROTECT, NULL, "unable to release object header")
+ }
FUNC_LEAVE_NOAPI_TAG(ret_value)
} /* end H5O_protect() */