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
This commit is contained in:
Dana Robinson 2023-10-25 21:16:32 -07:00 committed by GitHub
parent ebeb642fcd
commit 6ccace572e
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
2 changed files with 10 additions and 1 deletions

View File

@ -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

View File

@ -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