Skip to content

Commit

Permalink
Fixed a file handle leak in the core VFD (HDFGroup#3779)
Browse files Browse the repository at this point in the history
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 HDFGroup#635
  • Loading branch information
derobins authored and jhendersonHDF committed Dec 7, 2023
1 parent 6976faa commit b9b9b6c
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 1 deletion.
7 changes: 7 additions & 0 deletions release_docs/RELEASE.txt
Original file line number Diff line number Diff line change
Expand Up @@ -109,6 +109,13 @@ Bug Fixes since HDF5-1.14.3 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

- Dropped support for MPI-2

The MPI-2 supporting artifacts have been removed due to the cessation
Expand Down
4 changes: 3 additions & 1 deletion src/H5FDcore.c
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down

0 comments on commit b9b9b6c

Please sign in to comment.