Skip to content

Commit

Permalink
malloc --> calloc in H5B cache entry (#5053)
Browse files Browse the repository at this point in the history
oss-fuzz occasionally complains about intermittent undefined behavior
when when Boolean variables in H5C_cache_entry_t (like is_protected)
are set to values other than 0 or 1 when parsing fuzzed files. Using
calloc() to iniitialize the H5B_t struct (like other metadata already
does) should fix this.
  • Loading branch information
derobins authored Oct 31, 2024
1 parent 8f0cdce commit 92033df
Showing 1 changed file with 1 addition and 1 deletion.
2 changes: 1 addition & 1 deletion src/H5B.c
Original file line number Diff line number Diff line change
Expand Up @@ -215,7 +215,7 @@ H5B_create(H5F_t *f, const H5B_class_t *type, void *udata, haddr_t *addr_p /*out
/*
* Allocate file and memory data structures.
*/
if (NULL == (bt = H5FL_MALLOC(H5B_t)))
if (NULL == (bt = H5FL_CALLOC(H5B_t)))
HGOTO_ERROR(H5E_BTREE, H5E_CANTALLOC, FAIL, "memory allocation failed for B-tree root node");
memset(&bt->cache_info, 0, sizeof(H5AC_info_t));
bt->level = 0;
Expand Down

0 comments on commit 92033df

Please sign in to comment.