Skip to content

Commit 0531c0c

Browse files
committed
Update path buffer sizes to hold slashes
1 parent 0a0ad89 commit 0531c0c

1 file changed

Lines changed: 4 additions & 4 deletions

File tree

src/H5VLcache_ext.c

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -5481,7 +5481,7 @@ static herr_t create_file_cache_on_local_storage(void *obj, void *file_args,
54815481
char *base = basename(name_buf);
54825482

54835483
size_t path_len =
5484-
strlen(file->H5LS->path) + strlen(base) + strlen("-cache") + 2;
5484+
strlen(file->H5LS->path) + strlen(base) + strlen("-cache/") + 2;
54855485
file->H5DWMM->cache->path = (char *)malloc(path_len);
54865486
if (file->H5DWMM->cache->path == NULL) {
54875487
LOG_ERROR(-1, "Failed to allocate cache path");
@@ -5565,7 +5565,7 @@ static herr_t create_file_cache_on_local_storage(void *obj, void *file_args,
55655565
strncpy(name_buf, name, sizeof(name_buf) - 1);
55665566
name_buf[sizeof(name_buf) - 1] = '\0';
55675567
char *base = basename(name_buf);
5568-
size_t path_len = strlen(file->H5LS->path) + strlen(base) + 2;
5568+
size_t path_len = strlen(file->H5LS->path) + strlen(base) + 3; // 3 for two slashes and null
55695569
file->H5DRMM->cache->path = (char *)malloc(path_len);
55705570
if (file->H5DRMM->cache->path == NULL) {
55715571
LOG_ERROR(-1, "Failed to allocate file read cache path");
@@ -5739,7 +5739,7 @@ static herr_t create_dataset_cache_on_local_storage(void *obj, void *dset_args,
57395739

57405740
if (dset->H5LS->path != NULL) {
57415741
// Build cache path: <parent_cache_path>/<dataset_name>/
5742-
size_t path_len = strlen(p->H5DRMM->cache->path) + strlen(name) + 2;
5742+
size_t path_len = strlen(p->H5DRMM->cache->path) + strlen(name) + 3; // 3 for two slashes and null
57435743
dset->H5DRMM->cache->path = (char *)malloc(path_len);
57445744
if (dset->H5DRMM->cache->path == NULL) {
57455745
LOG_ERROR(-1, "Failed to allocate dataset read cache path");
@@ -5844,7 +5844,7 @@ static herr_t create_group_cache_on_local_storage(void *obj, void *group_args,
58445844
memcpy(group->H5DRMM->mpi, o->H5DRMM->mpi, sizeof(MPI_INFO));
58455845
if (group->H5LS->path != NULL) {
58465846
// Build cache path: <parent_cache_path>/<group_name>/
5847-
size_t path_len = strlen(o->H5DRMM->cache->path) + strlen(name) + 2;
5847+
size_t path_len = strlen(o->H5DRMM->cache->path) + strlen(name) + 3; // 3 for two slashes and null
58485848
group->H5DRMM->cache->path = (char *)malloc(path_len);
58495849
if (group->H5DRMM->cache->path == NULL) {
58505850
LOG_ERROR(-1, "Failed to allocate group read cache path");

0 commit comments

Comments
 (0)