summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorDana Robinson <43805+derobins@users.noreply.github.com>2023-10-26 04:16:32 (GMT)
committerGitHub <noreply@github.com>2023-10-26 04:16:32 (GMT)
commit6ccace572e99561adf820af686da19f9a31efee3 (patch)
tree8ae3089ddb03f0bb03c6cd2528f1eb9fc542029a
parentebeb642fcdc3c82dec38c046948559119cd4451b (diff)
downloadhdf5-6ccace572e99561adf820af686da19f9a31efee3.zip
hdf5-6ccace572e99561adf820af686da19f9a31efee3.tar.gz
hdf5-6ccace572e99561adf820af686da19f9a31efee3.tar.bz2
Fixed a file handle leak in the core VFD (#3779)
When opening a file with the core VFD and a file image, if the file already exists, the file check would leak the POSIX file handle. Fixes GitHub issue #635
-rw-r--r--release_docs/RELEASE.txt7
-rw-r--r--src/H5FDcore.c4
2 files changed, 10 insertions, 1 deletions
diff --git a/release_docs/RELEASE.txt b/release_docs/RELEASE.txt
index 291f72a..7266de3 100644
--- a/release_docs/RELEASE.txt
+++ b/release_docs/RELEASE.txt
@@ -404,6 +404,13 @@ Bug Fixes since HDF5-1.14.0 release
===================================
Library
-------
+ - Fixed a file handle leak in the core VFD
+
+ When opening a file with the core VFD and a file image, if the file
+ already exists, the file check would leak the POSIX file handle.
+
+ Fixes GitHub issue #635
+
- Fixed some issues with chunk index metadata not getting read
collectively when collective metadata reads are enabled
diff --git a/src/H5FDcore.c b/src/H5FDcore.c
index 08b714d..1aa8d4b 100644
--- a/src/H5FDcore.c
+++ b/src/H5FDcore.c
@@ -754,8 +754,10 @@ H5FD__core_open(const char *name, unsigned flags, hid_t fapl_id, haddr_t maxaddr
((file_image_info.buffer == NULL) && (file_image_info.size == 0)));
memset(&sb, 0, sizeof(sb));
if ((file_image_info.buffer != NULL) && !(H5F_ACC_CREAT & flags)) {
- if (HDopen(name, o_flags, H5_POSIX_CREATE_MODE_RW) >= 0)
+ if ((fd = HDopen(name, o_flags, H5_POSIX_CREATE_MODE_RW)) >= 0) {
+ HDclose(fd);
HGOTO_ERROR(H5E_FILE, H5E_FILEEXISTS, NULL, "file already exists");
+ }
/* If backing store is requested, create and stat the file
* Note: We are forcing the O_CREAT flag here, even though this is