Skip to content

Commit

Permalink
Fix some potential segfaults (#30)
Browse files Browse the repository at this point in the history
Fix release builds of connector
  • Loading branch information
jhendersonHDF authored Jun 10, 2024
1 parent c27f1ee commit 3e52d5a
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 6 deletions.
6 changes: 3 additions & 3 deletions src/H5VLcache_ext.c
Original file line number Diff line number Diff line change
Expand Up @@ -1074,6 +1074,7 @@ static herr_t H5VL_cache_ext_init(hid_t vipl_id) {
// Initialize local storage struct, create the first one
H5LS_stack = (H5LS_stack_t *)malloc(sizeof(H5LS_stack_t));
H5LS_stack->next = NULL;
H5LS_stack->H5LS = NULL;
if (!getenv("ABT_THREAD_STACKSIZE"))
setenv("ABT_THREAD_STACKSIZE", "100000", 1);
// setenv("HDF5_ASYNC_DISABLE_IMPLICIT_NON_DSET_RW", "1", 1);
Expand Down Expand Up @@ -1150,6 +1151,7 @@ static herr_t H5VL_cache_ext_term(void) {
while (current->next != NULL) {
next = current->next;
free(current->H5LS);
current->H5LS = NULL;
free(current);
current = next;
}
Expand Down Expand Up @@ -1467,10 +1469,8 @@ static herr_t H5VL_cache_ext_str_to_info(const char *str, void **_info) {
p->H5LS->cache_io_cls = &H5LS_cache_io_class_global_g; //
}

p->next = (H5LS_stack_t *)malloc(sizeof(H5LS_stack_t));
p->next = (H5LS_stack_t *)calloc(1, sizeof(H5LS_stack_t));
p = p->next;
p->next = NULL;
p->H5LS = NULL;

/* Set return value */
*_info = info;
Expand Down
6 changes: 3 additions & 3 deletions utils/debug.c
Original file line number Diff line number Diff line change
Expand Up @@ -142,8 +142,8 @@ void *my_malloc(const char *file, int line, const char *func, size_t size) {
if (HDF5_CACHE_LOG_LEVEL >= DEBUG)
printf(" [CACHE VOL][DEBUG] MEMORY Allocated \n\t <%s:%i:%s>: %p[%li]\n",
file, line, func, p, size);
return p;
#endif
return p;
}

void *my_calloc(const char *file, int line, const char *func, int count,
Expand All @@ -153,8 +153,8 @@ void *my_calloc(const char *file, int line, const char *func, int count,
if (HDF5_CACHE_LOG_LEVEL >= DEBUG)
printf(" [CACHE VOL][DEBUG] MEMORY Allocated \n\t <%s:%i:%s>: %p[%dx%li]\n",
file, line, func, p, count, size);
return p;
#endif
return p;
}

void my_free(const char *file, int line, const char *func, void *p) {
Expand All @@ -164,4 +164,4 @@ void my_free(const char *file, int line, const char *func, void *p) {
line, func, p);
#endif
free(p);
}
}

0 comments on commit 3e52d5a

Please sign in to comment.