summaryrefslogtreecommitdiffstats
path: root/tools
diff options
context:
space:
mode:
authorvchoi-hdfgroup <55293060+vchoi-hdfgroup@users.noreply.github.com>2023-05-11 19:03:09 (GMT)
committerGitHub <noreply@github.com>2023-05-11 19:03:09 (GMT)
commit2a3d2ef785541135e4f10e4c4a89feb001baf832 (patch)
tree218e9767650fcb4b976eed81fc54ddff6b3ea59c /tools
parent811f5b5c9d8907658a6c883e9fa3bd20831b4054 (diff)
downloadhdf5-2a3d2ef785541135e4f10e4c4a89feb001baf832.zip
hdf5-2a3d2ef785541135e4f10e4c4a89feb001baf832.tar.gz
hdf5-2a3d2ef785541135e4f10e4c4a89feb001baf832.tar.bz2
New 1 10 hdffv 11052 (#2932)
Fix for HDFFV-11052: h5debug fails on a corrupted file (h5_nrefs_POC) producing a core dump. When h5debug closes the corrupted file, the library calls H5F__dest() which performs all the closing operations for the file "f" (H5F_t *) but just keeping note of errors in "ret_value" all the way till the end of the routine. The user-provided corrupted file has an illegal file size causing failure when reading the image during the closing process. At the end of this routine it sets f->shared to NULL and then frees "f". This is done whether there is error or not in "ret_value". Due to the failure in reading the file earlier, the routine then returns error. The error return from H5F__dest() causes the file object "f" not being removed from the ID node table. When the library finally exits, it will try to close the file objects in the table. This causes assertion failure for f->file_id > 0. Fix: a) H5F_dest(): free the f only when there is no error in "ret_value" at the end of the routine. b) H5F__close_cb(): if f->shared is NULL, free "f"; otherwise, perform closing on "f" as before. c) h5debug.c main(): track error return from H5Fclose().
Diffstat (limited to 'tools')
-rw-r--r--tools/src/misc/h5debug.c8
1 files changed, 6 insertions, 2 deletions
diff --git a/tools/src/misc/h5debug.c b/tools/src/misc/h5debug.c
index 7706fd4..ad7e1a6 100644
--- a/tools/src/misc/h5debug.c
+++ b/tools/src/misc/h5debug.c
@@ -808,8 +808,12 @@ main(int argc, char *argv[])
done:
if (fapl > 0)
H5Pclose(fapl);
- if (fid > 0)
- H5Fclose(fid);
+ if (fid > 0) {
+ if (H5Fclose(fid) < 0) {
+ HDfprintf(stderr, "Error in closing file!\n");
+ exit_value = 1;
+ }
+ }
/* Pop API context */
if (api_ctx_pushed)